Re: [xml] Newbie Help



Supplying the leading / is one of the permutations of the _expression_ that I have already tried.  When I do this, I *do not* get the error messages:

xmlXPathNodeCollectAndTest xpath.c:1923 : nodelist and node are NULL

However, xpath_object is still returned as NULL.  According to the documentation, even if there are no matches, shouldn't I receive back a valid pointer to an empty list?

On Mon, 2004-08-09 at 14:45, Daniel Veillard wrote:
On Mon, Aug 09, 2004 at 02:39:10PM -0500, Bryan Christ wrote:
> Please help!
> 
> I have generated an xml file using kxmleditor.  With libxml, I am trying
> to use the xpath interface to retrieve a node list for the elements in
> my file.  The document has (currently) a three level hierarchy and I am
> trying to retrieve data from the inner most tier.  My code snippet:
> 
> if(!(xmldoc=xmlParseFile("statics.xml"))) break;
> xpath_context=xmlXPathNewContext(xmldoc);
> xpath_object=xmlXPathEvalExpression((xmlChar*)"root/main_ui/config_menu/*",xpath_context);
> 
> When I run my code, I get the following error messages:
> 
> xmlXPathNodeCollectAndTest xpath.c:1923 : nodelist and node are NULL
> xmlXPathNodeCollectAndTest xpath.c:1923 : nodelist and node are NULL
> xmlXPathNodeCollectAndTest xpath.c:1923 : nodelist and node are NULL
> xmlXPathNodeCollectAndTest xpath.c:1923 : nodelist and node are NULL

  The current node is not defined. Strange but possible, 

> Apparently, each one of these error messages corresponds to each level
> of the hierarchy.  I have tried many permutations of the same
> _expression_.  In all cases xpath_object is returned invalid.  I suspect
> my syntax for the _expression_ is wrong, but I cannot figure it out.

  Try /root/main_ui/config_menu/* The leading / ask XPath to start
from the root of the document.

> Also, I have studied the code example at
> http://www.xmlsoft.org/tutorial/apd.html and have reviewed the syntax
> for xpath as describe here
> http://www.w3.org/TR/xpath#section-Introduction.  Neither has helped. 
> As far as I can tell, my code is really the same as that provided by the
> example.  Please help!

  Check that example:
    http://xmlsoft.org/examples/index.html#xpath1.c
but it looks really similar. 

Daniel


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