In Java how do I evaluate XPATH expression on XML using SAX Parser?
Need more dynamic way because the XML format is not fixed. So i should be able pass the following
- xpath as string
- xml as string / input source
Something like Utility.evaluate("/test/@id='123'", "")
Here is an exemple :
EDIT :
If you want to use a SAX parser, then you can't use the XPath object of Java, see https://docs.oracle.com/javase/7/docs/api/javax/xml/xpath/package-summary.html
If you want to use SAX you can look at libs detailed in this question : Is there any XPath processor for SAX model? .
Although the mechanic of XPath does not really suit SAX. Indeed using a SAX parser won't create an XML tree in memory. Hence you can't use XPath efficiently because it won't see not loaded nodes.