[xml] Using Xpath from a node



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.

<A>
   <B>
   :
   </B>   
   
   <B>
      <C>xxx</C>      
      <D>
         <E>yyy</E>
      </D>   
   </B>
</A>

Thanks in advance

Sruli Ganor



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