com.gargoylesoftware.htmlunit.html.xpath
Class HtmlUnitXPath

java.lang.Object
  extended by org.jaxen.BaseXPath
      extended by com.gargoylesoftware.htmlunit.html.xpath.HtmlUnitXPath
All Implemented Interfaces:
java.io.Serializable, org.jaxen.XPath

public class HtmlUnitXPath
extends org.jaxen.BaseXPath

Jaxen XPath adapter implementation for the HtmlUnit DOM model

This is the main entry point for matching an XPath against a HU-DOM tree. You create a compiled XPath object, then match it against one or more context nodes using the BaseXPath.selectNodes(Object) method, as in the following example:

 XPath path = new HtmlUnitXPath("a/b/c");
 List results = path.selectNodes(domNode);
 

Version:
$Revision: 1.3 $
Author:
Christian Sell, Mike Bowler, Marc Guillemot
See Also:
BaseXPath, Serialized Form

Constructor Summary
HtmlUnitXPath(java.lang.String xpathExpr)
 Construct given an XPath expression string.
HtmlUnitXPath(java.lang.String xpathExpr, org.jaxen.Navigator navigator)
 Construct given an XPath expression string and a Document Navigator.
 
Method Summary
static org.jaxen.Navigator buildSubtreeNavigator(DomNode node)
 Builds a navigator that will see the provided node as the "document" and only navigate in its children.
 java.lang.String toString()
 Gives the xpath expression provided to c'tor.
 
Methods inherited from class org.jaxen.BaseXPath
addNamespace, booleanValueOf, debug, evaluate, getFunctionContext, getNamespaceContext, getNavigator, getRootExpr, getVariableContext, numberValueOf, selectNodes, selectSingleNode, setFunctionContext, setNamespaceContext, setVariableContext, stringValueOf, valueOf
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HtmlUnitXPath

public HtmlUnitXPath(java.lang.String xpathExpr)
              throws org.jaxen.JaxenException
Construct given an XPath expression string.

Parameters:
xpathExpr - The XPath expression.
Throws:
org.jaxen.JaxenException - if there is a syntax error while parsing the expression.

HtmlUnitXPath

public HtmlUnitXPath(java.lang.String xpathExpr,
                     org.jaxen.Navigator navigator)
              throws org.jaxen.JaxenException
Construct given an XPath expression string and a Document Navigator.

Parameters:
xpathExpr - The XPath expression.
navigator - the document navigator to use for evaluation
Throws:
org.jaxen.JaxenException - if there is a syntax error while parsing the expression.
Method Detail

buildSubtreeNavigator

public static org.jaxen.Navigator buildSubtreeNavigator(DomNode node)
Builds a navigator that will see the provided node as the "document" and only navigate in its children.
The returned navigator can only be used to evaluate xpath expressions on nodes of the same document as the provided one. The behavior when used on an other document is undefined.

Parameters:
node - the node that should be considered as the root by the navigator
Returns:
a navigator

toString

public java.lang.String toString()
Gives the xpath expression provided to c'tor.

Overrides:
toString in class org.jaxen.BaseXPath
Returns:
the xpath expression provided to c'tor.
See Also:
BaseXPath.toString()


Copyright © 2003-2009 AppPerfect Corporation. All Rights Reserved.