public class XPathAccess
extends java.lang.Object
Constructor and Description |
---|
XPathAccess(org.w3c.dom.Document document)
Initialize the new instance with the given document's root element.
|
XPathAccess(org.w3c.dom.Element element)
Initialize the new instance with the element to work on.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
evaluate(java.lang.String xpathStr,
javax.xml.namespace.QName returnType) |
org.w3c.dom.Element |
getElement() |
org.w3c.dom.Element |
getElement(java.lang.String xpathStr)
Evaluates the given XPath expression against the underlying element and returns
the found element.
|
java.util.List<org.w3c.dom.Element> |
getElements(java.lang.String xpathStr)
Evaluates the given XPath expression against the underlying element and returns
the found elements.
|
org.w3c.dom.Node |
getNode(java.lang.String xpathStr)
Evaluates the given XPath expression against the underlying element and returns
the found node or null.
|
java.util.List<org.w3c.dom.Node> |
getNodes(java.lang.String xpathStr)
Evaluates the given XPath expression against the underlying element and returns
the found nodes as list.
|
java.lang.String |
getNodeText(java.lang.String xpathStr)
Evaluates the given XPath expression against the underlying element and returns
the text of the found element or attribute.
|
void |
setElement(org.w3c.dom.Element newValue) |
public XPathAccess(org.w3c.dom.Element element)
public XPathAccess(org.w3c.dom.Document document)
public org.w3c.dom.Element getElement()
public void setElement(org.w3c.dom.Element newValue)
public java.lang.String getNodeText(java.lang.String xpathStr)
The method automatically creates the necessary NamespaceContext from the underlying element in order to support prefixed names in the XPath.
xpathStr
- The XPath expression to evaluateXPathAccessException
- If the given expression cannot be evaluatedpublic org.w3c.dom.Element getElement(java.lang.String xpathStr)
The method automatically creates the necessary NamespaceContext from the underlying element in order to support prefixed names in the XPath.
xpathStr
- The XPath expression to evaluateXPathAccessException
- If the given expression cannot be evaluatedpublic java.util.List<org.w3c.dom.Element> getElements(java.lang.String xpathStr)
The method automatically creates the necessary NamespaceContext from the underlying element in order to support prefixed names in the XPath.
xpathStr
- The XPath expression to evaluateXPathAccessException
- If the given expression cannot be evaluatedpublic org.w3c.dom.Node getNode(java.lang.String xpathStr)
The method automatically creates the necessary NamespaceContext from the underlying element in order to support prefixed names in the XPath.
xpathStr
- The XPath expression to evaluateXPathAccessException
- If the given expression cannot be evaluatedpublic java.util.List<org.w3c.dom.Node> getNodes(java.lang.String xpathStr)
The method automatically creates the necessary NamespaceContext from the underlying element in order to support prefixed names in the XPath.
xpathStr
- The XPath expression to evaluateXPathAccessException
- If the given expression cannot be evaluatedprotected java.lang.Object evaluate(java.lang.String xpathStr, javax.xml.namespace.QName returnType)