Re: [xml] XPath on a subtree
- From: Daniel Veillard <veillard redhat com>
- To: Alex Bligh <alex alex org uk>
- Cc: xml gnome org
- Subject: Re: [xml] XPath on a subtree
- Date: Sat, 23 Mar 2013 21:54:54 +0800
On Sat, Mar 23, 2013 at 12:09:25PM +0000, Alex Bligh wrote:
Daniel,
On 23 Mar 2013, at 11:52, Daniel Veillard wrote:
ctxt->node = node;
actually it's good to set the doc too at that point before reusing
the context in the loop.
ctxt->doc = doc;
res = xmlXPathEval("./foo..", ctxt);
...
of course the subtree query will have to be relative, i.e. not
starting by /
Ah! The point I'd missed is that you can set ctxt->node. I couldn't
see an API call to set the current node. Could I suggest this might
be a useful function (if only an inline) so it gets into the docs?
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
libxml2mod.xmlXPathSetContextNode()
we could do something along this line in C or another way could be
to add a new function:
xmlXPathObjectPtr
xmlXPathNodeEval(xmlNodePtr node, const xmlChar *str, xmlXPathContextPtr ctx)
as a simple wrapper around xmlXPathEval
Daniel
--
Daniel Veillard | Open Source and Standards, Red Hat
veillard redhat com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | virtualization library http://libvirt.org/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]