Re: [xml] Setting a context from a patricular node
- From: "James Dennett" <jdennett technocom-wireless com>
- To: <xml gnome org>
- Cc: eric_w <rice cruft gmail com>
- Subject: Re: [xml] Setting a context from a patricular node
- Date: Fri, 21 Dec 2007 10:49:49 -0800
(Top-posting fixed.)
eric_w wrote:
James Dennett wrote:
-----Original Message-----
From: xml-bounces gnome org [mailto:xml-bounces gnome org] On
Behalf
Of
Abhishek Jain
Sent: Wednesday, November 07, 2007 3:22 PM
To: xml gnome org
Subject: [xml] Setting a context from a patricular node
Hi,
I want to set the xmlXPathContext from a particular node say
xmlNodePtr
node1 in a xmlDocPtr doc so that my XPath is evaluated in the
subtree
of
node1.
Please let me know how can i do that.
While I'd be more comfortable if I could find this documented, so
far as
I can tell the recommended approach is to set the "node" field of
the
xmlXPathContext, i.e., context->node = node1; in your case.
I'd also note that some library calls will change the node, so you
should reset it before reusing a context.
-- James
Doesn't this sequence
doc = xmlTextReaderCurrentDoc( reader);
pathContext = xmlXPathNewContext( doc);
accomplish the same thing?
I don't see how it could, given that it does not even mention
a "current node". But I could be missing something. Could
you show how you'd implement code to evaluate an XPath relative
to a specified node within a document?
Or are you suggesting that is is sufficient to
just set the xmlNodePtr
in the path context structure?
I don't completely understand your question. Obviously it is
Necessary to initialize the context using xmlXPathNewContext;
after that, I believe the context node can be changed within
the context, and I don't know of a function call to do so,
although some function calls change the current node as a
side-effect.
-- James
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]