class Main extends Sprite
{
public function new()
{
super();
try
{
var xml:Xml = Xml.parse("<count>6</count>");
trace(xml.nodeType);
for (x in xml.elementsNamed("count"))
{
trace(x.nodeName);
trace(x.nodeType);
trace(x.nodeValue);
}
}
catch (err:Dynamic)
{
trace(err);
Sys.exit(1);
}
}
}
Output:
Main.hx:23: 6
Main.hx:27: count
Main.hx:28: 0
Main.hx:34: Bad node type, unexpected 0
I can't fully understand the principle of operation of nodeValue property. Because of that, I can't solve my problem. Any help here?
P.S. My configuration is: Haxe + OpenFL targeting Neko.
elementsNamed()returns nodes of typeXmlType.Element, and the docs fornodeValueexplicitly state:So
nodeValuewill work for all other possibleXmlTypevalues. In your case, the value you want to retrieve is stored in aXmlType.PCDatanode, and you can access it usingfirstChild():The full structure of
<count>6</count>looks like this: