Re: [xml] XPath relative search?
- From: Daniel Veillard <veillard redhat com>
- To: "Christopher J. Grayce" <cgrayce aleks com>
- Cc: xml gnome org
- Subject: Re: [xml] XPath relative search?
- Date: Wed, 17 Sep 2003 04:22:02 -0400
On Tue, Sep 16, 2003 at 11:25:05PM -0700, Christopher J. Grayce wrote:
(gdb) print xp_context->node->type
$29 = XML_ELEMENT_NODE
(gdb) print xp_context->node->name
$30 = (const xmlChar *) 0x8063a30 "instance"
(gdb) next
132 if ((xp_nodes = xp_result->nodesetval)) {
(gdb) print xp_context->node->type
$31 = XML_DOCUMENT_NODE <---- huh??
(gdb) print xp_context->node->name
$32 = (const xmlChar *) 0x0 <---- huh??
--------------
That is, the act of calling xmlXPathEval seems to reset the
xmlXPathNewContext to the top of the document.
Bahh, register allocation, debugger and code compiled
with -O2 can lead to some surprise, I assume it's the problem,
or maybe the function resets the current evaluation node,
that should not be a problem. xp_result should still have
the result of the query.
How, then, does one do a relative XPath search? I'm mystified.
Set xp_context->node to the current node before calling the
XPath evaluation function, and use a relative search, //text
is an absolute search ! .//text is the relative version c.f.
http://www.w3.org/TR/xpath
Daniel
--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]