package
{
import flash.display.Sprite;
public class XmlAttributes extends Sprite
{
protected var xml:XML = <root>
<country id="0">
<states id="0_0">
<city id="0_0_0">
<village id="0_0_0_0"></village>
<village id="0_0_0_1"></village>
<village id="0_0_0_2"></village>
</city>
</states>
<states id="0_1">
</states>
</country>
<country id="1"></country>
</root>;
public function XmlAttributes()
{
super();
var result:XML = depthFirstSearch(xml);
trace(result.localName());
}
public function depthFirstSearch(node:XML):XML
{
for each (var child:XML in node.children())
{
if (("@id" in child) && (child.@id == "0_0_0_1"))
return child;
else
{
var result:XML = depthFirstSearch(child);
if(result)
return result;
}
}
return null;
}
}
}
The XML tags in the code example above are being stripped - not sure why they cannot be encoded / escaped. It is the XML from your example.