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?
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:
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:exif='http://schemas.google.com/photos/exif/2007' xmlns:gphoto='http://schemas.google.com/photos/2007' xmlns:media='http://search.yahoo.com/mrss/' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gml='http://www.opengis.net/gml' xmlns:georss='http://www.georss.org/georss' >
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.
EDIT: can I mark my own posts as answered?
See past threads on namespaces