Re: [xml] found issue in xpath tutorial

Just wanted to know if there are any comments regarding the patch.

Is it ok to copy data from result->nodesetval->nodeTab[i]->children->content instead of using function 

The reason for not using xmlNodeListGetString, is in case of query such as /hello/world/text(), the function 
xmlNodeListGetString returns NULL even though element /hello/world has data, and the function would work fine 
if /hello/world query was used instead.

The patch is a bit more complicated than just using the direct lookup, such that it finds the first 
XML_TEXT_NODE, and gets data from there.

-----Original Message-----
From: Beylin, Alex
Sent: Fri 9/8/2006 6:12 PM
To: xml gnome org
Subject: [xml] found issue in xpath tutorial


I think I have found an issue in this tutorial:


I am providing a patch (xpath.c.patch), but not sure if you'll agree
with it.


The call to function xmlNodeListGetString has been removed, and now
there is a lookup for the value directly in the xmlNode structure.


The reason being, is this query does not work:


I updated the sample code to accept the query on the command line, and
it coredumps with above, because the function xmlNodeListGetString
returns NULL.  For test, I used xpath.xml document, and ran this query:

./xpath xpath.xml "/story/storyinfo[author/@id="2"]/author/text()"


If anyone has any other suggestions as to how the coredump can befixed,
without modifying the query, as I believe it's valid, please let me


I understand that this query would work:

But I don't see why valid query such as original should fail, unless
it's invalid, than please explain why.



We are coding application calling these API's, and I would like to know
if my fix to sample program is valid, and could be incorporated into the
application, or if some other function should be called to get the value
(maybe actually the function xmlNodeListGetString should be updated?).



Thank you.



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