tags:

views:

155

answers:

1

I am wondering whether it is possible to use relative XPath expressions in libxml2.

This is from the javax.xml.xpath API and I would like to do the similar thing using libxml2:

Node widgetNode = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);

With a reference to the element, a relative XPath expression can now written to select the child element:

XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "manufacturer";
Node manufacturerNode = (Node) xpath.evaluate(expression, **widgetNode**, XPathConstants.NODE);
+1  A: 

Set the node member of your xmlXPathContext object.

Steven Ourada