Abstract way to get a XMLList of child nodes by name

Harrison

New Member
I'm trying to build an abstract method to get all the nodes in an XML object by node name. I don't know the structure of the XML ahead of time. So with this code I would like to get a list of all "item" nodes and all "x" nodes:\[code\]var xml:XML = <root><items><item/><item/><item><x/><item><item><x/></item></items></root>var nodeName:String;var list:XMLList;list = getNodeByName(xml, "item"); // contains no resultslist = getNodeByName(xml, "x"); // contains no results// what am i doing wrong here?public static function getNodeByName(xml:XML, nodeName:String):XMLList { return xml.child(nodeName);}\[/code\]
 
Back
Top