Access XML nodes with integer names

debbieroyal

New Member
For my application, I make an HTTPRequest, and get back some XML served from a JSP. That XML has some (yes, I'm aware this is invalid/improper XML. If I can't find a bandaid, I will try to address that internally) nodes with integers as names, say \[code\]<2>\[/code\] for example. When I attempt to access it, using \[code\]myXMLVariable.child("2")\[/code\], it returns the third (index=2) XML node instead. I understand that this behavior is "correct". Is there any way to get around this behavior?Example\[code\]var myXML:String = "<response>" + "<place1>" + " <item>1</item>" + " <stuff>1</stuff>" + "</place1>" + "<2>" + " <item>1</item>" + " <stuff>1</stuff>" + "</2>" + "<place3>" + " <item>1</item>" + " <stuff>1</stuff>" + "</place3>" + "</response>";protected function getParam():void{ var xml:XML = new XML(myXML); Alert.show(xml.child("2")); //trace(xml.child("2"))}\[/code\]\[code\]xml.child("2")\[/code\] returns\[code\]<place3> ...</place3>\[/code\]...when I want\[code\]<2> ...</2>\[/code\]NOTEI am aware this is invalid XML. I am looking for a workaround, a short term fix. There is a near-future release date, and this workaround will be removed and replaced with proper XML for the next version.
 
Back
Top