|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jaxen.BaseXPath
org.jaxen.dom.html.HTMLXPath
An XPath implementation for the W3C HTML DOM model
This is an XPath providing element and attribute case-management for HTML documents. Because HTML is case-insensitive, but stores DOM elements in upper case, it is difficult to write XPath queries for HTML documents which are also compatible with their XHTML equivalents. This class converts the element, but not attribute, names of an HTML document to upper or lower case, depending on your specification, so that lower case [element] xpath expressions will work just as well on HTML as they do on XHTML (which is case sensitive and enforces lower case on elements and attributes). Note that HTML attribute names are stored as lower case in the HTML (and XHTML) DOM already which is why the case of attribute names are not modified.
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 HTMLXPath("a/b/c", true); // convert to lower case List results = path.selectNodes(htmlNode);
BaseXPath
,
DOMXPath
,
Serialized FormConstructor Summary | |
HTMLXPath(java.lang.String xpathExpr)
Constructs a new XPath, treating all elements as lower case. |
|
HTMLXPath(java.lang.String xpathExpr,
boolean toLowerCase)
Construct given an XPath expression string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public HTMLXPath(java.lang.String xpathExpr, boolean toLowerCase) throws JaxenException
xpathExpr
- the XPath expressiontoLowerCase
- if true, all element names will be considered to
be lower case. Otherwise, they will be upper case.
JaxenException
- if there is a syntax error while
parsing the expressionpublic HTMLXPath(java.lang.String xpathExpr) throws JaxenException
xpathExpr
- the XPath expression
JaxenException
- if there is a syntax error while
parsing the expression
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |