[xml] Problems with XPath

I'm trying to get all the organization elements in this XML document. The XML document is a bit like this (heavily simplified) example:


I used this code to get at the organizations:

        xmlDoc* doc = WholeRoot->doc;
        xmlChar* xpathExpr = (xmlChar*)"/manifest/organizations/organization";

        xmlXPathContext* xpathCtx = xmlXPathNewContext(doc);
        RT_Assert( xpathCtx, "Unable to create new XPath context." );
        xmlXPathObject* xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
        RT_Assert( xpathObj, "Unable to evaluate xpath expression." );
        RT_Assert( xpathObj->nodesetval, "No organizations found!." );

What happens, is that I get "No organizations found". Despite that the document really does contain elements at the path "/manifest/ organizations/organization" !

Is it:

1) My XPath query is wrong.
2) My XML file doesn't really look like I think it does.
3) My code is wrong.
4) There is a bug in libxml2?

My guess the problem is with my code or my XPath query. Any ideas anyone?

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