Re: [xml] XPath on a subtree

On Sat, Mar 23, 2013 at 02:10:42PM +0000, Alex Bligh wrote:

On 23 Mar 2013, at 13:54, Daniel Veillard wrote:

 I though I had added a macro but searched for it an no it's not there.
In the python bindings there is an extra function called


That was what I was thinking of, but ...

xmlXPathNodeEval(xmlNodePtr node, const xmlChar *str, xmlXPathContextPtr ctx)

as a simple wrapper around xmlXPathEval

... that would be equally useful.

  Do you mind doing a patch ? :-)

actually it's good to set the doc too at that point before reusing
the context in the loop.

     ctxt->doc = doc;

Isn't the doc set when you create the context? xmlXPathNewContext takes
a doc ptr.

  yes but it's better to have the node and the doc in sync. Some XPath
evaluation may reset the doc (from libxslt, probably impossible in
practice from libxml2).


Daniel Veillard      | Open Source and Standards, Red Hat
veillard redhat com  | libxml Gnome XML XSLT toolkit | virtualization library

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]