2 Replies Latest reply on Feb 18, 2010 9:33 AM by grefel

    XML Object / Parsing




      I have an XML file, comprised of a well-formed IDMS document, that is accessed from an xml rpc call. In a .jsx script, I save the IDMS string to a temp .idms file and use the place() function to perform an insertion into the active document.


      The issue I am having is that the text content of certain elements is Base 64 encoded. I need to decode these element contents prior to saving the xml string out to a file for place usage. In order to decode the Base 64, I create a new XML object from the xml string representing the IDMS, i.e. var xmlObj = new XML(stringFromIDMSFile). I then try to access elements with either xmlObj.children("elementName") or other functions, some of which take specific element names and some not, but I can't access any elements successfully. It doesn't error out but I get no XML object(s) back.


      Am I misinterpretting the API (probably)? When I then finally do xmlObj.toXMLString(), I get the full, original IDMS xml doc back out and it places successfully, but I can't seem to access any document nodes / contents in the API to manipulate them before the file save.


      I'm new to Extendscript and CS4. Any help appreciated.





        • 1. Re: XML Object / Parsing
          smitty265 Level 1

          I finally figured this out. The name of the variable has to be the same as the name of the root element in the xml string.


          For example:


          var Root = new XML('<Root><child>offspring</child></Root>');


          Then you use the variable to create references to elements / properties / values within the xml, i.e. var myKidsName = Root.child.toString();

          • 2. Re: XML Object / Parsing
            grefel Level 2



            i work a lot with xml... but this works fine too....


            var _variable = new XML('<Root><child>offspring</child><child2>offspring2</child2></Root>');


            no need to name your variable after the xml Element...

            guees your original code had another problem.


            all the best,