Re: [xml] Using Xpath from a node



On Wed, Feb 18, 2004 at 11:50:40AM +0200, Israel Ganor wrote:
Hi,

I've just starting using libxml2.
I wonder if there is a way to the the context of an element using a relative
Xpath expression. E.g., soppose my xmlNodePtr points to the last B element
(see below). Now I want to directly read the text of subelement E, without
looping through all B's subelements. Is this possible? The only way I found
so far is to build the full Xpath of E (from the doc's root) and get it
using the full expression, but this looks like an non-elegant and
inefficient.

  You need to change the evaluation context xmlXPathContextPtr
ctxt->doc should point to the current document, and ctxt->node should
point to the current node (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]