Hello everyone,
I have been trying to code a program that just retrieves an xml file over the internet and reads it and prints the info I want.
In order to do so, I am using wamp and daniel cassidy’s haxe-xpath that I got from github.
This small project was supposed to just take 5 min but it has been more than three days . I don’t know what I did wrong and where.
Here is my simple xml file:
<?xml version="1.0" encoding="utf-8"?>
<a>
<b>
<c>eh ben voilà</c>
</b>
</c>
Here is my class main:
class Main extends Sprite{
var xml:Xml;
var xmlLoader:URLLoader = new URLLoader();
var xpathXml:XPathHxHxml;
function new(){
super();
xmlLoader.addEventListener(Event.COMPLETE,onComplete);
xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, onError);
xmlLoader.load(new URLRequest("http://localhost/example.xml");
}
function onError(err:IOErrorEvent){trace("the error is: "+err);}
function onComplete(e:Event){
xml = Xml.Parse(xmlLoader.data);
xmlLoader.removeEventListener(Event.COMPLETE,onComplete);
xmlLoader.removeEventListener(IOErrorEvent.onError);
xpathXml = XPathHxXml.warpNode(xml);
var xpathExpression = new Xpath("/a/b/c");
var result = xpathExpression.evaluate(xpathXml);
trace(result);
}
}
I was hoping to have result from Trace saying “eh ben Voilà!”
but what I got was different:
{ booleanValue => false, nodes => { iterator => #function:0 }, typeName => node set, numberValue => 0, stringValue => }
now my question is, did I forget something?
or if the traced result is the correct one, how do I retrieve data from my xml using xpath