1 Reply Latest reply on Mar 23, 2010 10:14 AM by Ian Proudfoot

    Can't read processing instructions from XML

    Ian Proudfoot Level 3

      I am trying to read the contents of some XML processing instructions using this bit of JavaScript:

       

      XMLFile.open('r');
      var readXMLFile = XMLFile.read();
      XMLFile.close();

      var book = new XML (readXMLFile);

       

      var PIcontent = book.processingInstruction('pgw');

       

      This should return the content of the PI such as <?pgw 8.5i?> which would hopefully mean that PIcontent === '8.5i'.

       

      I thought I had found the source of the problem by using the static property XML.ignoreProcessingInstructions = false; but although that made the PI show up in book, it made no difference wth the handling of processing instructions.

       

      I also tried using xpath, but again with no luck.

       

      The cut-down XML looks like this:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE book SYSTEM "book.dtd">
      <book xml:lang="en">
          <?pgw 8.5i?>
          <?pgh 11i?>
          <?slug true?>

          <?info true?>
          <title>Example XML fragment</title>
      </book>

       

      Thanks to anyone who may know what's going on here.

      Ian