PDA

View Full Version : DOMQuery help required



kondurucs
24 Feb 2009, 7:36 AM
Hi

I dont see the data inside the array after I pass the xmlDocument to DomQuery. Can you take a look at the below code and suggest if you see anything wrong.
thanks
-chandra

v var docStr;
function parseXML(xmlData) {
if (window.ActiveXObject) {
docStr = new ActiveXObject("Microsoft.XMLDOM");
docStr.async = "false";
docStr.loadXML(xmlData);
} else {
docStr = new DOMParser().parseFromString(xmlData, "text/xml");
}
}
var appStr = '<users><user>Robert></user><user>Keith</user></users>';
Ext.onReady(function() {
parseXML(appStr);
var root = docStr.documentElement || docStr;
var q=Ext.DomQuery;
var arr=q.select('/users/user',root);
for(var i in arr){
alert(arr[i]);
}
})

is there anyproblem with the above code. I see arr being empty instead of getting populated with user Robert and keith

Animal
24 Feb 2009, 7:42 AM
Play with it on the Firebug console command line until you get the hang!