简体   繁体   中英

VTD-XML: how to execute XPath query not from the root element

I need to handle large XML files, and I decided to move from DOM parser to VTD-XML.

When I used Java's DOM parser, I could evaluate XPath queries from any node, not from the root. Look at XPath.evaluate prototype:

Object evaluate(String expression,
                Object item,
                QName returnType)
                   throws XPathExpressionException

Object item is the starting context (a node, for example). This is very useful.

But I can't find the way to do the same in VTD-XML. I have read its API and read many examples, for instance, this one , but everywhere queries are executed from the root.

How to do that?

Ok, it seems I got it: actually, XPath queries are always executed relative to the current VTDNav 's cursor position.

Check out this example , look for the section "Nested XPath support".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM