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"));
|
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!