XPathEvaluator

This object is available to unprivileged JavaScript. It implements the following interfaces:

Methods

XPathExpression createExpression ( String expression , XPathNSResolver resolver ) XPathNSResolver createNSResolver ( Node nodeResolver ) nsISupports evaluate ( String expression , Node contextNode , XPathNSResolver resolver , short type , nsISupports result )

XPathExpression createExpression ( String expression , XPathNSResolver resolver )

Arguments:
expression
resolver

XPathNSResolver createNSResolver ( Node nodeResolver )

Arguments:
nodeResolver

nsISupports evaluate ( String expression , Node contextNode , XPathNSResolver resolver , short type , nsISupports result )

Arguments:
expression
contextNode
resolver
type
result

Reference documentation is generated from Mozilla's source.

Add a note User Contributed Notes
May 9, 2005, 6:34 pm otto at atrus dot org
A good tutorial about using XPath in Javascript:
http://www-jcsu.jesus.cam.ac.uk/~jg307/mozilla/xpath-tutorial.html
January 4, 2005, 2:07 am wanderingstan at XXmorethanwarmXXmail dot com
Handy utility function:
function xPathSearch(aXmlDoc, aXpath)
{
var pXPE = new XPathEvaluator();
var foundNodes = new Array();

var result = pXPE.evaluate(aXpath, aXmlDoc, pXPE.createNSResolver(aXmlDoc.documentElement), 0, null);
while (res = result.iterateNext())
{
foundNodes.push(res);
}
return foundNodes;
}

Copyright © 1999 - 2005 XULPlanet.com