[haXe] xml parsing

Nicolas Cannasse ncannasse at motion-twin.com
Tue Apr 25 19:42:58 CEST 2006


> thanks for your answer.
> however, looks like i cant get it working.
> 
> here's my xml:
> 
> <items>
> 	<id value="1"/>
> 	<id value="2"/>
> 	<id value="3"/>
> </items>
> 
> my code is like:
> 
> class XmlTest{
> 	static public function main(){
> 	 var s= XmlParser.parse(Std.resource("myxml"));
> 	 for(i in 0...s.firstChild.childNodes.length)
> 		trace(s.firstChild.childNodes[i].nodeValue);
> 	 }
> }
> 
> all i get is null;
> nodeName works as expected, though.
> i am missing something?

First the XmlParser is returning you a "document".
So you should be able to trace the "items" this way :

for(x in s.firstChild.childNodes)
    trace(x.nodeName);

Nicolas



More information about the Haxe mailing list