我想知道是否可以在libxml2中使用相对XPath表达式.
这是来自javax.xml.xpath API,我想使用libxml2做类似的事情:
Node widgetNode = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);
Run Code Online (Sandbox Code Playgroud)
通过对元素的引用,现在可以编写相对XPath表达式来选择子元素:
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "manufacturer";
Node manufacturerNode = (Node) xpath.evaluate(expression, **widgetNode**, XPathConstants.NODE);
Run Code Online (Sandbox Code Playgroud)