5 Replies Latest reply on Jul 1, 2015 7:18 AM by Sajeev Sridharan

    How to add contents into the xml element?

    vidhyar34646163

      I need to insert a word sqrt(plain text without tags ) in the xml element of m:msqrt like below:

      enter image description here

      I tried ,

           

      var path = (app.activeDocument.fullName.parent.fsName).toString().replace(/\\/g, '/');//path of active document(sample.indd)

           

          var xmlPath = (app.activeDocument.fullName.parent.fsName).toString().replace(/\\/g, '/')+"/with_aid2.xml";

          xmlFile = File (xmlPath);

          if(xmlFile.exists){

          xmlFile.open();

          var myString = xmlFile.read();

          xmlFile.close();

          myXml = new XML ();

          myXml = XML(myString);

          var msqrtCount = myXml.xpath("//m:msqrt");

        

          }else{alert(xmlPath+" doesn't exist!");}

        

        

          for(var i=0;i<msqrtCount.length();i++){

          var added =    msqrtCount[i];

              added.contents="sqrt";     

            

              }

       

      I get an error says invalid content property.