Using the API
Here is a small example of how to listen for XPath events while scanning a document:
XPathEventHandler matchIdHandler = new XPathEventHandler() { public void onMatch(XPathEvent event) throws XMLStreamException { match = true; } }; XPathBuilder builder = new XPathBuilder(); builder.addPrefix("c", "urn:customer"); builder.listen("//c:id[text()='2']", matchIdHandler); XPathEvaluator evaluator = builder.compile(); evaluator.evaluate(getClass().getResourceAsStream("customer.xml"));
Supported Concepts
Currently only a limited subset of XPath is supported. We are working to add more as time goes on. If a particular function or features is missing, please file a JIRA request for it!
- /foo/bar - simple axis iterators
- //foo
- Attributes - /foo[@bar]
- Expressions:
- "and"
- "or"
- "=" - i.e. text() = '2'
- Functions:
- text()
- local-name()
- namespace-uri()
Labels
(None)
