Re: [xml] XPath context



On Fri, Apr 20, 2001 at 01:12:27PM -0400, carl douglas convergys com wrote:
Hi,

Would someone mind explaining to me what effect setting
the node member in a xmlXPathContext structure has on
an X Path evaluation.

for example,

ctxt = xmlXPathNewContextPtr(doc);
ctxt->node = xmlDocGetRootElement(doc);

result = xmlXPathEval( BAD_CAST"/book/chapter[1]/descendant::*", ctxt");

  won't change anything for this XPath expression but is very
important when you do a relative path query like:

  "chapter[1]/descendant::*"

 if you're placed at the root would will have a different answer as
if placed at /book

  You can play with relative and absolut XPath queries when using
xmllint --shell yourfile

  the cd/ls/etc... commands uses a XPath expressions to locate their
target nodes.

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
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]