Ok, you may have a namespace problem. They can be a PITA. I'm not an expert and you should reveiw the docs/google if this doesn't work but try putting this in the declarations section of your app/component(instance scope level):
default xml namespace = ""http://www.w3.org/2005/Atom"; There is more stuff in the xmlns declaration in your sample xml: <feed xmlns="http://www.w3.org/2005/Atom <http://www.w3.org/2005/Atom> " ... I do not understand what that second part of the string is. You might have to include that as well in the default namespace declaration. You can avoid the namespace issue if you use the node index to get a node, but this is a very clunky way to do it. To see, try: Alert.show(myXML.children()[4].toXMLString()) XMLList always has 0-n xml nodes in it. (the result of an e4x expression is never null) If there is only one node, then many of the XML methods will work on it the same as with XML. But for clarity, if I know I want to work with a single XML node then I do: var myXMLList:XMLList = myXML.logo; var xmlLogo:XML = myXMLList[0]; If just you do this below, you will get a datatype error: var xmlLogo:XML = myXML.logo; //even if that expression returns only a single node. Tracy ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of wild.katana Sent: Thursday, May 22, 2008 7:08 PM To: [email protected] Subject: [flexcoders] Re: How to extract data from XML Okay, first of all, thanks for all of your help, Tracy. I have checked the myXML variable with Alert.show(myXML) and it shows what I pasted in the first post (that's where I got it). So I know that myXML contains that. I tried doing Alert.show(myXML.logo.toXMLString()) but it is still showing nothing. I have read the documentation on using XML and tried many of the things it says, but to no avail. One thing I don't wuite understand... What is the difference between XML and XMLList? If the myXML.logo returns an XMLList, then should I make a variable that contains it first? Like var myXMLList:XMLList = myXML.logo; Alert.show(myXMLList); ? I will try that but let me know if that is what you were meaning or not... Thanks again.. --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Tracy Spratt" <[EMAIL PROTECTED]> wrote: > > First, did you trace or alert your XML in yur result handler? If you > did not and are assuming you know what your xml looks like exactly, do > that now. > > > > Second, when attempting to view XML, always use toXMLString() (search > the archives for why): > > Alert.show(myXML.logo.toXMLString()) > > > > Third, when writing e4x expressions, unless you are very certain of > yourself, it is best to do it one step at a time, using temporary XML > or XMLList variables as needed, and tracing the contained value using > toXMLString(). Note that all e4x expressions(myXML.logo is one) return > XMLList, not XML. The docs will show how to handle this. > > > > Fourth, review the XML class in the language Ref and the "working with > data" cha[ter in the developers guide for an explanation on how to work > with XML. The link below is for Flex 2, but the XML stuff has not > changed. > > http://livedocs.adobe.com/flex/2/docs/00001910.html <http://livedocs.adobe.com/flex/2/docs/00001910.html> > > > > Tracy > > > > ________________________________ > > From: [email protected] <mailto:flexcoders%40yahoogroups.com> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of wild.katana > Sent: Thursday, May 22, 2008 4:00 AM > To: [email protected] <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] How to extract data from XML > > > > Hello, I have loaded an XML from a URL using URLLoader. Now that I > have it in an object, how do I access individual parts of that data? > The XML looks like this: > <feed xmlns="http://www.w3.org/2005/Atom <http://www.w3.org/2005/Atom> <http://www.w3.org/2005/Atom <http://www.w3.org/2005/Atom> > " > xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/ <http://a9.com/-/spec/opensearchrss/1.0/> > <http://a9.com/-/spec/opensearchrss/1.0/ <http://a9.com/-/spec/opensearchrss/1.0/> > " > xmlns:gml="http://www.opengis.net/gml <http://www.opengis.net/gml> <http://www.opengis.net/gml <http://www.opengis.net/gml> > " > xmlns:georss="http://www.georss.org/georss <http://www.georss.org/georss> > <http://www.georss.org/georss <http://www.georss.org/georss> > " > xmlns:media="http://search.yahoo.com/mrss/ <http://search.yahoo.com/mrss/> > <http://search.yahoo.com/mrss/ <http://search.yahoo.com/mrss/> > " > xmlns:yt="http://gdata.youtube.com/schemas/2007 <http://gdata.youtube.com/schemas/2007> > <http://gdata.youtube.com/schemas/2007 <http://gdata.youtube.com/schemas/2007> > " > xmlns:gd="http://schemas.google.com/g/2005 <http://schemas.google.com/g/2005> > <http://schemas.google.com/g/2005 <http://schemas.google.com/g/2005> > "> > <id>http://gdata.youtube.com/feeds/api/videos <http://gdata.youtube.com/feeds/api/videos> > <http://gdata.youtube.com/feeds/api/videos <http://gdata.youtube.com/feeds/api/videos> > </id> > <updated>2008-05-22T07:54:46.868Z</updated> > <category scheme="http://schemas.google.com/g/2005#kind <http://schemas.google.com/g/2005#kind> > <http://schemas.google.com/g/2005#kind <http://schemas.google.com/g/2005#kind> > " > term="http://gdata.youtube.com/schemas/2007#video <http://gdata.youtube.com/schemas/2007#video> > <http://gdata.youtube.com/schemas/2007#video <http://gdata.youtube.com/schemas/2007#video> > "/> > <title type="text">YouTube Videos matching query: football > -soccer</title> > <logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif <http://www.youtube.com/img/pic_youtubelogo_123x63.gif> > <http://www.youtube.com/img/pic_youtubelogo_123x63.gif <http://www.youtube.com/img/pic_youtubelogo_123x63.gif> > </logo> > <link rel="alternate" type="text/html" href="http://www.youtube.com <http://www.youtube.com> > <http://www.youtube.com <http://www.youtube.com> > "/> > <link rel="http://schemas.google.com/g/2005#feed <http://schemas.google.com/g/2005#feed> > <http://schemas.google.com/g/2005#feed <http://schemas.google.com/g/2005#feed> > " > type="application/atom+xml" > href="http://gdata.youtube.com/feeds/api/videos <http://gdata.youtube.com/feeds/api/videos> > <http://gdata.youtube.com/feeds/api/videos <http://gdata.youtube.com/feeds/api/videos> > "/> > <link rel="self" type="application/atom+xml" > href="http://gdata.youtube.com/feeds/api/videos?start-index=11&max-r <http://gdata.youtube.com/feeds/api/videos?start-index=11&max-r> > esults=10&orderby=published&vq=football+-soccer > <http://gdata.youtube.com/feeds/api/videos?start-index=11&max-result <http://gdata.youtube.com/feeds/api/videos?start-index=11&max-result > > s=10&orderby=published&vq=football+-soccer> "/> > <link rel="previous" type="application/atom+xml" > href="http://gdata.youtube.com/feeds/api/videos?start-index=1&max-re <http://gdata.youtube.com/feeds/api/videos?start-index=1&max-re> > sults=10&orderby=published&vq=football+-soccer > <http://gdata.youtube.com/feeds/api/videos?start-index=1&max-results <http://gdata.youtube.com/feeds/api/videos?start-index=1&max-results > > =10&orderby=published&vq=football+-soccer> "/> > <link rel="next" type="application/atom+xml" > href="http://gdata.youtube.com/feeds/api/videos?start-index=21&max-r <http://gdata.youtube.com/feeds/api/videos?start-index=21&max-r> > esults=10&orderby=published&vq=football+-soccer > <http://gdata.youtube.com/feeds/api/videos?start-index=21&max-result <http://gdata.youtube.com/feeds/api/videos?start-index=21&max-result > > s=10&orderby=published&vq=football+-soccer> "/> > <author> > <name>YouTube</name> > <uri>http://www.youtube.com/ <http://www.youtube.com/> <http://www.youtube.com/ <http://www.youtube.com/> > </uri> > </author> > ... > > So let's say I wanted to access the information in the logo element, > how would I do this? My code looks like this: > > public var myLoader:URLLoader; //declare this outside of a function. > The leading underscore is just a convention > public var myXML:XML; //this too > > private function initUrlLoader():void { > > var XML_URL:String > ="http://gdata.youtube.com/feeds/api/videos?vq=football+-soccer&orderby= <http://gdata.youtube.com/feeds/api/videos?vq=football+-soccer&orderby=> > published&start-index=11&max-results=10 > <http://gdata.youtube.com/feeds/api/videos?vq=football+-soccer&orderby=p <http://gdata.youtube.com/feeds/api/videos?vq=football+-soccer&orderby=p > > ublished&start-index=11&max-results=10> "; > var myXMLURL:URLRequest = new URLRequest(XML_URL); > myLoader = new URLLoader(myXMLURL); > myLoader.addEventListener("complete", xmlLoaded); > } > > private function xmlLoaded(event:Event):void > { > myXML = XML(myLoader.data); > trace("Data loaded."); > // I want to pop up the information in the logo element > Alert.show(myXML.logo); > } > > The alert box isn't showing anything though... What am I doing wrong? > Thanks >

