Hi all,
I have an xml like this :
This is stored in a file. i am loading it at runtime like this :
Till here it works fine ... file is loaded correctly and everything. Then i am doing something like this :
The function selectSingleNod e is as follows :
But Node is returning null even if the url is clearly present as an attribute.
Any ideas ?
Regards ,
Rhitam
I have an xml like this :
Code:
<root> <url newurl="something.asp?folder/file.htm#somethingsomething" /> <root>
Code:
var xmlDoc; xmlDoc.load(Filepath);
Till here it works fine ... file is loaded correctly and everything. Then i am doing something like this :
Code:
var xpath="",Url,Node;
Url = window.location.href.split(window.location.host+"/")[1]; //To get the part after the host ... this is the same format that is there in the "newurl" attribute of the xml shown above
xpath="url[@newurl='"+Url+"']";
Node = selectSingleNode(xmlDoc.documentElement,xpath);
Code:
function selectSingleNode(sElem,sXPath) {
if(sElem==null) return null;
try{// IE
return sElem.selectSingleNode(sXPath);
}
catch(ee){//Firefox and other browsers
var oEvaluator = new XPathEvaluator();
// FIRST_ORDERED_NODE_TYPE returns the first match to the xpath.
var oResult = oEvaluator.evaluate(sXPath, sElem, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (oResult != null) {
return oResult.singleNodeValue;
}
else {
return null;
}
}
}
Any ideas ?
Regards ,
Rhitam
Comment