public final class XPathHelper extends Object
| Modifier and Type | Method and Description |
|---|---|
static NodeList |
evaluateXpathExpression(Document dom,
String xpathExpr)
Returns the list of nodes which match the expression xpathExpr in the Document dom.
|
static NodeList |
evaluateXpathExpression(String domStr,
String xpathExpr)
Returns the list of nodes which match the expression xpathExpr in the String domStr.
|
static String |
formatXPath(String xpath) |
static int |
getCloseElementLocation(String dom,
int pos,
String element) |
static int |
getCloseElementLocation(String dom,
String xpath) |
static String |
getLastElementXPath(String xpath) |
static List<Node> |
getSiblings(Node parent,
Node element)
Get siblings of the same type as element from parent.
|
static String |
getXPathExpression(Node node)
Reverse Engineers an XPath Expression of a given Node in the DOM.
|
static com.google.common.collect.ImmutableList<String> |
getXpathForXPathExpressions(Document dom,
String xpathExpression)
Returns the XPaths of all nodes retrieved by xpathExpression.
|
static int |
getXPathLocation(String dom,
String xpath)
returns position of xpath element which match the expression xpath in the String dom.
|
static String |
stripXPathToElement(String xpath) |
public static String getXPathExpression(Node node)
node - the given node.public static List<Node> getSiblings(Node parent, Node element)
parent - parent node.element - element.public static NodeList evaluateXpathExpression(String domStr, String xpathExpr) throws XPathExpressionException, IOException
XPathExpressionExceptionIOExceptionpublic static NodeList evaluateXpathExpression(Document dom, String xpathExpr) throws XPathExpressionException
dom - the Document to search inxpathExpr - the xpath queryXPathExpressionException - On error.public static com.google.common.collect.ImmutableList<String> getXpathForXPathExpressions(Document dom, String xpathExpression) throws XPathExpressionException
dom - The dom.xpathExpression - The expression to find the element.XPathExpressionExceptionpublic static String formatXPath(String xpath)
xpath - The xpath to format.public static String getLastElementXPath(String xpath)
xpath - The xpath expression to find the last element of.public static int getXPathLocation(String dom, String xpath)
dom - the Document to search inxpath - the xpath querypublic static int getCloseElementLocation(String dom, int pos, String element)
dom - The dom string.pos - Position where to start searching.element - The element.public static int getCloseElementLocation(String dom, String xpath)
dom - The dom.xpath - The xpath expression.Copyright © 2007-2013. All Rights Reserved.