On Fri, Mar 01, 2013 at 01:55:19PM +0000, Richard W.M. Jones wrote:
> I have some code (below) which segfaults because xmlXPathEvalExpression
> returns:
>
> (gdb) print *labelObj
> $1 = {type = XPATH_NODESET, nodesetval = 0x0, boolval = 0, floatval = 0,
> stringval = 0x0, user = 0x0, index = 0, user2 = 0x0, index2 = 0}
>
> I have previously thought it was impossible for xmlXPathEvalExpression
> to return something != NULL but with nodesetval == NULL, but obviously
> it can do this.
>
> But what does it mean?
>
it means the evaluation type is a node set but the query failed
to return anything. Empty node sets may either have nodesetval as NULL
or nodesetval->nodeNr == 0 in the XPath return values.
> It doesn't seem to mean "no nodes", because when I use the standalone
> 'xpath' program (which AIUI uses libxml2) it returns a single matching
> node.
it is Perl which use XML::XPath and i don't think it uses libxml2
> Rich.
But i agree there is something going on, libxml2 find the nodes
thinkpad:~/XML -> xmllint --shell tst.xml
/ > xpath /domain/seclabel[@model='selinux']/label
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT label
/ > xpath /domain/seclabel[@model='selinux']/imagelabel
Object is a Node Set :
Set contains 1 nodes:
1 ELEMENT imagelabel
/ >
Daniel
--
Daniel Veillard | Open Source and Standards, Red Hat
[email protected] | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | virtualization library http://libvirt.org/
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
[email protected]
https://mail.gnome.org/mailman/listinfo/xml