|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectca.infoway.messagebuilder.j5goodies.XPathHelper
public class XPathHelper
A utility to make XPath operations easier.
This utility supports both namespace-based and non-namespaced based operations. If the provided node was created with a namespace-aware parser, then you must use the namespace version of these methods.
For example:
NodeList list = new XPathHelper().getNodes(document, "//x:myElement", "urn:mySchema.example.org");
In this example, the "x" prefix acts as a simple marker for the namespace; it doesn't matter what the name of the prefix is.
Constructor Summary | |
---|---|
XPathHelper()
|
Method Summary | |
---|---|
String |
getAttributeValue(Node base,
String xpathExpression,
String namespace)
Get an attribute value. |
NodeList |
getNodes(Node base,
String xpathExpression)
Get a list of nodes. |
NodeList |
getNodes(Node base,
String xpathExpression,
String namespace)
Get a list of nodes. |
Node |
getSingleNode(Node base,
String xpathExpression)
Get a single node. |
Node |
getSingleNode(Node base,
String xpathExpression,
String namespace)
Get a single node. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XPathHelper()
Method Detail |
---|
public Node getSingleNode(Node base, String xpathExpression) throws XPathExpressionException
Get a single node.
base
- - the base nodexpathExpression
- - the xpath expression.
XPathExpressionException
- - if the XPath is not validpublic NodeList getNodes(Node base, String xpathExpression) throws XPathExpressionException
Get a list of nodes.
base
- - the base nodexpathExpression
- - the xpath expression.
XPathExpressionException
- - if the XPath is not validpublic NodeList getNodes(Node base, String xpathExpression, String namespace) throws XPathExpressionException
Get a list of nodes.
base
- - the base nodexpathExpression
- - the xpath expression (namespace aware).namespace
- - the namespace.
XPathExpressionException
- - if the XPath is not validpublic Node getSingleNode(Node base, String xpathExpression, String namespace) throws XPathExpressionException
Get a single node.
base
- - the base nodexpathExpression
- - the xpath expression (namespace aware).namespace
- - the namespace.
XPathExpressionException
- - if the XPath is not validpublic String getAttributeValue(Node base, String xpathExpression, String namespace) throws XPathExpressionException
Get an attribute value.
base
- - the base nodexpathExpression
- - the xpath expression (namespace aware).namespace
- - the namespace.
XPathExpressionException
- - if the XPath is not valid
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |