public final class PathParsers extends Object
Example use:
Path el = div.before(span);
String xpath = el.getXPath().get();
NodeList nodes = findAllByXpath("<div>foo</div><div>boo</div><span></span>", el);
assertThat(nodes.getLength(), is(2));
assertThat(nodes.item(0).getTextContent(), equalTo("foo"));
| Modifier and Type | Method and Description |
|---|---|
static NodeList |
findAllByPath(Document doc,
Path path)
find all the nodes that match a path in a W3C document
|
static NodeList |
findAllByPath(String docString,
Path path)
find all the nodes that match a path in a W3C document
|
static NodeList |
findAllByXPath(Document doc,
String extractedXpath)
internal implementation
|
static Document |
getDocumentFromString(String document)
Convert a string to a
Document, Assuming utf-8 encoding. |
public static Document getDocumentFromString(String document) throws ParserConfigurationException, IOException, SAXException
Document, Assuming utf-8 encoding.document - the document as a stringParserConfigurationExceptionIOExceptionSAXExceptionpublic static NodeList findAllByPath(String docString, Path path) throws XPathExpressionException, IOException, SAXException, ParserConfigurationException
docString - a W3C documentpath - the path to find.XPathExpressionExceptionIOExceptionSAXExceptionParserConfigurationExceptionpublic static NodeList findAllByPath(Document doc, Path path) throws XPathExpressionException
doc - a W3C documentpath - the path to findXPathExpressionExceptionpublic static NodeList findAllByXPath(Document doc, String extractedXpath) throws XPathExpressionException
doc - a W3C documentextractedXpath - an xpathXPathExpressionExceptionCopyright © 2018. All rights reserved.