2 Replies Latest reply on Dec 21, 2010 3:17 PM by Flex harUI

    XML object returns attributes but not elements




      I'm very new to this so my problem is probably down to bad practices but anyhow... I have code as follows:


      var s:String = load.data; //This turns up as fully-formed correct XML every time.
      var docx:XML = new XML(s);
      trace(new String(docx..@src));
      trace(new String(docx..entry));


      In the above the first trace works fine and returns the value of all 'src' attributes found in the document.


      However, the second statement does nothing at all. It should return a list of 'entry' nodes I think.


      The XML document I'm using is found here: http://picasaweb.google.com/data/feed/api/all


      Is the XML object malfunctioning or is my code wrong?





        • 1. Re: XML object returns attributes but not elements
          semprance Level 1

          Turns out it was a namespace issue. Here's an explanation for others who get stuck with a similar issue.


          I added these lines to the script in my mxml file:



          private namespace webNameSpace = "http://www.w3.org/2005/Atom";
          use namespace webNameSpace;



          The string "http://www.w3.org/2005/Atom" is taken from the root node of my xml document. In this case it was from the tag:






          Presumably, if I want to use tags that have NS prefixes (eg <gphoto:url>) then I'll need to add the other namespaces for use.


          Still, if anyone has any comments on whether there is a cleaner way to do this, or even just to let me know I'm doing it right, then please post back as I'm very knew to this and would like my code to be corrected/affirmed if possible.


          Thanks all,




          EDIT: can I mark my own posts as answered?

          • 2. Re: XML object returns attributes but not elements
            Flex harUI Adobe Employee

            See past threads on namespaces

            1 person found this helpful