Reputation: 197
I found this following XML example but am not sure how the xpath data can be obtained in C++ (besides using boost ptree xmlparser).
/* Evaluate xpath expression */
xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
if(xpathObj == NULL) {
fprintf(stderr,"Error: unable to evaluate xpath expression \"%s\"\n", xpathExpr);
xmlXPathFreeContext(xpathCtx);
xmlFreeDoc(doc);
return;
}
//cout <<"REsult : "<<xpathObj->stringval<<endl; /* Fails with bus error */
Upvotes: 0
Views: 434
Reputation: 1762
What exactly is contained in xpathObj depends on what your xpath expression matches. If you're looking to just get text out of it, you can iterate over nodes in xpathObj->nodesetval, calling xmlNodeListGetString, as show in the example.
http://www.xmlsoft.org/tutorial/ar01s05.html
Upvotes: 1