List of utility methods to do XPath Select
String | selectString(String xpath, Object node) select String return ((String) evaluateXPath(xpath, node, XPathConstants.STRING)).trim();
|
List | selectStrings(String xpath, Object node) select Strings List<String> values = new ArrayList<String>(); for (Node it : selectNodes(xpath, node)) { String textContent = getTextContent(it); if (textContent.length() > 0) { values.add(textContent); return values; ... |
String | selectXPathString(final String xPath, final Node inNode, final String nsuri, final String pre) select X Path String return (String) getNodesListXpath(xPath, inNode, nsuri, pre, XPathConstants.STRING);
|
List | xmlSelectNodes(Node node, String xpathExpression) Oh, for a decent xml library ;). List list = new LinkedList(); String path[] = split(xpathExpression, "/"); xmlSelectNodes0(list, node, path, 0); return list; |
NodeList | XPathAPI_selectNodeList(Document doc, String xpath, Node namespaceNode) X Path APselect Node List XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); setNamespace(xPath, xpath); try { XPathExpression xPathExpression = xPath.compile(xpath); return (NodeList) xPathExpression.evaluate(doc, XPathConstants.NODESET); } catch (XPathExpressionException e) { throw new TransformerException("Exception in XPathAPI_selectNodeList: " + xpath, e); ... |
Node | xpathNode(String expr, Document doc) xpath Node try { return (Node) xpath.evaluate(expr, doc, XPathConstants.NODE); } catch (Exception e) { throw new RuntimeException("Cannot evaluate XPath:", e); |
NodeList | xpathNodeList(String expr, Document doc) xpath Node List return (NodeList) xpath.evaluate(expr, doc, XPathConstants.NODESET);
|
String | xpathOrNull(Document doc, String xp) Evaluate an XPath against a Document, returning a String. XPathFactory factory = XPathFactory.newInstance(); XPath xpath = factory.newXPath(); try { XPathExpression expr = xpath.compile(xp); return expr.evaluate(doc); } catch (XPathExpressionException e) { return null; |
String | xpathString(String expr, Document doc) xpath String return (String) xpath.evaluate(expr, doc, XPathConstants.STRING);
|
Node | xpathToNode(Document document, String xpathExpression) xpath To Node XPath xpath = createXPath();
return (Node) xpath.evaluate(xpathExpression, document, XPathConstants.NODE);
|