5 Replies Latest reply on Jun 11, 2007 2:13 PM by injpix


    injpix Level 3
      I am trying to edit (insert a new attribute) into an XMLNode. The XML is returned from an external file, however once it is loaded I am trying to edit it and then insert back in the XMLNode (NOT the actually external file).
      I can’t get by the first part, parsing it. The second trace (temp_xml =) outputs nothing, I was hoping it would output the same as the first trace.
      Any suggestions?
        • 1. Re: parseXML()
          injpix Level 3
          I suppose using Flash's XPathAPI.setNodeValue() would be more ideal.
          • 2. Re: parseXML()
            Greg Dove Level 4
            I can't say because I've not used setNodeValue... I've used XPathAPI quite a bit for getting arrays of nodes or a single node, but I always end up using the regular AS2 node access properties for altering values.

            What you were trying to do with altering the attributes by text manipulaition is possible. Its just (after getting used to it) much better to use the XML/XMLNode class and maybe XPathAPI

            Your text manipulation was missing the single or double quotes around the attributes values.

            Here's a few examples for you to digest, based on what you had.

            • 3. Re: parseXML()
              injpix Level 3
              ah! Cool...yeah, XPathAPI is new to me. Just learned about it today in fact! Thanks for the info, i do need to change my code here to use the selectSingleNode(). Thanks.
              • 4. Re: parseXML()
                Greg Dove Level 4
                You don't have to use XPathAPI... but I'd suggest it makes life a bit easier.

                The line in my example

                is doing it without XPathAPI

                • 5. Re: parseXML()
                  injpix Level 3
                  I forgot to mention that my plan has slightly changed since I first posted this thread, I still need to access all attributes that have an value for ‘att’. I have a huge XML file with many different levels of nodes in which I need to find and archive those attributes. The code below is my first use of Xpath.

                  Do you think that there is a more elegant way of doing this, instead of adding several wildcards to the path?