Closed
Description
I have a project where I need to use functions defined from xpath 1.0 like count and strings. Here is the definition of count:
Function: number count(node-set)
The count function returns the number of nodes in the argument node-set.
when running with xmllint e.g. I can enter on this playlist.xml (http://grantm.github.io/perl-libxml-by-example/_static/xpath-sandbox/xpath-sandbox.html)
xmllint --xpath "count(//person)" playlist.xml
and I get the number 18 as a result.
When using libxml++ I get the error message from nodes/node.cc:88 Only nodeset result types are supported.
auto result = xmlXPathEval((const xmlChar*)xpath.c_str(), ctxt);
if (!result)
{
xmlXPathFreeContext(ctxt);
throw xmlpp::exception("Invalid XPath: " + xpath);
}
if (result->type != XPATH_NODESET)
{
xmlXPathFreeObject(result);
xmlXPathFreeContext(ctxt);
throw xmlpp::internal_error("Only nodeset result types are supported.");
Is there a way to use functions that have a result type that is not an xpath nodeset?
Metadata
Metadata
Assignees
Labels
No labels