I am trying to parse some XML of photos from Flickr. This is the xml that gets
returned when I load it:
<?xml version="1.0" encoding="utf-8" ?>
<rsp stat="ok">
<photos page="1" pages="94" perpage="10" total="937">
<photo id="95398437" owner="31524827@N00" secret="bde8208452" server="22"
title="Ocean Geyser" ispublic="1" isfriend="0" isfamily="0" />
<photo id="95176129" owner="31524827@N00" secret="cd3e392e3c" server="21"
title="Flower-Waterfall" ispublic="1" isfriend="0" isfamily="0" />
<photo id="95176128" owner="31524827@N00" secret="9a061efb1f" server="21"
title="Canyon-Sunrise" ispublic="1" isfriend="0" isfamily="0" />
<photo id="90008250" owner="31524827@N00" secret="afdb32e098" server="26"
title="Adam On the Mountain!" ispublic="1" isfriend="0" isfamily="0" />
<photo id="90008249" owner="31524827@N00" secret="98d13b240e" server="25"
title="Adam On the Chair Lift" ispublic="1" isfriend="0" isfamily="0" />
<photo id="90006085" owner="31524827@N00" secret="cb32ce55f0" server="38"
title="Mountains" ispublic="1" isfriend="0" isfamily="0" />
<photo id="90006084" owner="31524827@N00" secret="9b41a3c118" server="39"
title="Adam!" ispublic="1" isfriend="0" isfamily="0" />
<photo id="90006083" owner="31524827@N00" secret="6797eeeaeb" server="39"
title="Mountain Peaks" ispublic="1" isfriend="0" isfamily="0" />
<photo id="90006082" owner="31524827@N00" secret="c4975d34b3" server="41"
title="Mountain View" ispublic="1" isfriend="0" isfamily="0" />
<photo id="90006081" owner="31524827@N00" secret="cf291435bb" server="35"
title="Four of Us - More Mountain View" ispublic="1" isfriend="0" isfamily="0"
/>
</photos>
</rsp>
I have attached my code below. I would think that using:
this.firstChild.firstChild.childNodes would return an array of the photo
element. For some reason it doesn't and I have no clue as to why. When I browse
through the debugger and look at myXML, the structure does not seem to match
the actual XML structure. Anyone know why? Could someone please help me out
with this?
var testarray:Array = Array();
function init () {
testarray = this.firstChild.firstChild.childNodes;
trace(this);
}
var myXML:XML = new XML();
myXML.onLoad = init;
myXML.load("http://www.flickr.com/services/rest/?method=flickr.people.getpublicp
hotos&api_key=852926b3827e18d90e6c29f205a0c8b3&user_id=31524827@N00&per_page=10&
page=1");
myXML.ignoreWhite;
myXML.ignoreWhite = true;
must be BEFORE the
myXML.load(...)
> I am trying to parse some XML of photos from Flickr. This is the xml that gets
> returned when I load it:
> <?xml version="1.0" encoding="utf-8" ?>
> <rsp stat="ok">
> <photos page="1" pages="94" perpage="10" total="937">
> <photo id="95398437" owner="31524827@N00" secret="bde8208452"
server="22"
> title="Ocean Geyser" ispublic="1" isfriend="0" isfamily="0" />
> <photo id="95176129" owner="31524827@N00" secret="cd3e392e3c"
server="21"
> title="Flower-Waterfall" ispublic="1" isfriend="0" isfamily="0" />
> <photo id="95176128" owner="31524827@N00" secret="9a061efb1f"
server="21"
> title="Canyon-Sunrise" ispublic="1" isfriend="0" isfamily="0" />
> <photo id="90008250" owner="31524827@N00" secret="afdb32e098"
server="26"
> title="Adam On the Mountain!" ispublic="1" isfriend="0" isfamily="0" />
> <photo id="90008249" owner="31524827@N00" secret="98d13b240e"
server="25"
> title="Adam On the Chair Lift" ispublic="1" isfriend="0" isfamily="0" />
> <photo id="90006085" owner="31524827@N00" secret="cb32ce55f0"
server="38"
> title="Mountains" ispublic="1" isfriend="0" isfamily="0" />
> <photo id="90006084" owner="31524827@N00" secret="9b41a3c118"
server="39"
> title="Adam!" ispublic="1" isfriend="0" isfamily="0" />
> <photo id="90006083" owner="31524827@N00" secret="6797eeeaeb"
server="39"
> title="Mountain Peaks" ispublic="1" isfriend="0" isfamily="0" />
> <photo id="90006082" owner="31524827@N00" secret="c4975d34b3"
server="41"
> title="Mountain View" ispublic="1" isfriend="0" isfamily="0" />
> <photo id="90006081" owner="31524827@N00" secret="cf291435bb"
server="35"
> title="Four of Us - More Mountain View" ispublic="1" isfriend="0" isfamily="0"
> />
[quoted text clipped - 15 lines]
> var myXML:XML = new XML();
> myXML.onLoad = init;
myXML.load("http://www.flickr.com/services/rest/?method=flickr.people.getpub
licp
hotos&api_key=852926b3827e18d90e6c29f205a0c8b3&user_id=31524827@N00&per_page
=10&
> page=1");
> myXML.ignoreWhite;