0 Replies Latest reply on Jun 18, 2013 5:35 AM by gopaljay78

    how to access xml element

    gopaljay78 Level 1

      Hi,

       

      In my ID CS5 document, I have an XML tag followed by the processing instruction.

       

      I have written the javascript code to access processing instruction. Is there a way to access the XML element preceding to this processing instructions.

       

       

      My code is:

      ------------------------

       

      #include "/Applications/Adobe InDesign CS4/Scripts/Xml Rules/glue code.jsx"

       

      var myDocument = app.activeDocument;

      var myRuleSet = new Array (new ProcessProduct);

       

      var myDoc = app.activeDocument;   

      with(myDocument)  {

          try  {

              var elements = xmlElements;

              __processRuleSet(elements.item(0), myRuleSet);

              }

          catch (err)  {  alert (err); }

          }

       

      function ProcessProduct()

      {

          this.name = "ProcessProduct";

          this.xpath = "//processing-instruction('floatref')"; //comment()";

          this.apply = function(myElement, myRuleProcessor)

          {

              with(myElement)

              {

                  myDoc.select(myElement);       

                  // ******************************************************************************

                  // HERE I NEED CODE TO ACCESS PREVIOUS XML ELEMENT

                  // ******************************************************************************

       

                  }

              return true;

              }

          }

       

       

      Thanks,

      Gopal