First, this not the right forum for that question. It should go in flexcoders. This forum is for extending and making custom components.
You can't use xml methods on a string, so load it into an XML object: var xmlTemp:XML = XML(name);//looks like a cast but is really a top-level function Now you can use XML methods like: var x:XMLList = xmlTemp.descendants(); Tracy -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of dan_of_philly Sent: Thursday, December 20, 2007 5:21 PM To: [email protected] Subject: [flexcomponents] Getting all XML child elements for a component's viewer Hey, I'm trying to get all the child nodes for an element in an XML tree given a node passed to a function as a string. For example, given the xml: <a> <first> <blah>...</blah> <foo>...</foo> <bar>...</bar> </first> <sec> <b2lah>...</b2lah> <f2oo>...</f2oo> <b2ar>...</b2ar> </sec> </a> that is stored in say : var xml XMLList = "<a> ..." and I have a function trying to return all the child nodes when given a certain element, how would I get the child nodes ? xml.. doesnt work if its a string. public function getChildNodes( name:String):XMLList { var x:XMLList = xml..name ; // doesnt work ! Looks for 'name' node return x; } Assuming name:String = "sec" , I would want the function to return: " <b2lah>...</b2lah> <f2oo>...</f2oo> <b2ar>...</b2ar> " Is the only answer to iterate through the entire tree ? That seems ridiculous ! I have a large xml tree, so I really dont want to iterate through it each time. Any help is appreciated. Thanks Yahoo! Groups Links
