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".
链接地址: http://www.djcxy.com/p/64748.html上一篇: PHP:如何用XMLWriter替换现有的XML节点
下一篇: XML:如何不从根元素执行XPath查询