RE: [xml] Using Xpath from a node

Thanks, it works fine.

Is there a performance penalty when working with (relative) Xpath to find a
single child of the current node, vs. looping through all the node's
children until I find the requested child? Assume the node itself has no
more than 10 child elements in one level only (no grandchildren).

Thanks in advance

Sruli Ganor

-----Original Message-----
From: Daniel Veillard [mailto:veillard redhat com] 
Sent: Wednesday, February 18, 2004 11:59 AM
To: Israel Ganor
Cc: 'xml gnome org'
Subject: Re: [xml] Using Xpath from a node

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

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 Veillard      | Red Hat Network
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]