Re: [xml] XPath api



On Thu, Jan 17, 2002 at 05:19:07PM +0100, Fabrice DESRE - FT.BD/FTRD/DMI/GRI wrote:
 Hello,

 I'm having difficulties to retrieve attribute values
using the XPath API. When using an XPath expression
like //*/@foo, the resulting xmlXPathObjectPtr is
a Node Set with 0 nodes. Not espacially useful.
Using string(//*/@foo), i get an empty string.
 You'll find my code below - it's really basic.
I've browsed the docs and list archives but didn't
find anything. 

  the best is to use the existing code part of the distribution.
In this case testXPath.c . The code do work:

orchis:~/XML -> cat tst.xml
<a><b foo="toto"/></a>
orchis:~/XML -> ./testXPath -i tst.xml '//*/@foo' 
Object is a Node Set :
Set contains 1 nodes:
1  ATTRIBUTE foo
    TEXT
      content=toto
orchis:~/XML -> 

  And the function testXPath() implementing it is not much longer
than yours.

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]