Assuming I have a XML with a list of collection. I would first make a XPath to extract all collections from my XML and then loop trough the resulting list of collections to parse those collections. Unfortunately with your original code, it is impossible to call XPath again on the resulting nodes.
However after checking the differences between a "doc" element and a result node, i realized they were almost the same...
A simple modification to your "SelectNodes" function does the trick :
function SelectNodes(doc, xpath)
{
var parser = new XPathParser();
var xpath = parser.parse(xpath);
var context = new XPathContext();
if(doc.documentElement){
context.expressionContextNode = doc.documentElement;
}else{
context.expressionContextNode = doc;
}
var res = xpath.evaluate(context)
return res.toArray();
}
Assuming I have a XML with a list of collection. I would first make a XPath to extract all collections from my XML and then loop trough the resulting list of collections to parse those collections. Unfortunately with your original code, it is impossible to call XPath again on the resulting nodes.
However after checking the differences between a "doc" element and a result node, i realized they were almost the same...
A simple modification to your "SelectNodes" function does the trick :
function SelectNodes(doc, xpath) { var parser = new XPathParser(); var xpath = parser.parse(xpath); var context = new XPathContext(); if(doc.documentElement){ context.expressionContextNode = doc.documentElement; }else{ context.expressionContextNode = doc; } var res = xpath.evaluate(context)
return res.toArray();
}