Skip to content

Instantly share code, notes, and snippets.

@magmoro
Created March 9, 2009 12:34
Show Gist options
  • Save magmoro/76231 to your computer and use it in GitHub Desktop.
Save magmoro/76231 to your computer and use it in GitHub Desktop.
XML.getNodes=function(node, xpath){
var found=[], foundNodes;
var root=node.ownerDocument||node;
if(Browser.Engine.trident){
root.setProperty("SelectionLanguage","XPath");
foundNodes=node.selectNodes(xpath)
for(var i=0, l=foundNodes.length; i<l; i++) found.push(foundNodes[i]);
}else{
foundNodes=root.evaluate(xpath, node, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i=0, l=foundNodes.snapshotLength; i<l; i++) found.push(foundNodes.snapshotItem(i));
}
return found;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment