Set XPath default namespace
As far as I'm aware, it's not possible to setup a default namespace for XPath querying. Consider the following document:
<?xml version="1.0"?>
<html xmlns="https://www.w3.org/1999/xhtml">
<head></head>
<body><p>hi</p></body>
</html>
The default namespace is the XHTML namespace, and all nodes belong to that namespace.
When I use the query //p
nothing will be returned because it queries for p elements that are not in a namespace.
I'd like to override this behaviour, i.e. setup XPath to use the XHTML namespace when no explicit prefix is provided.
xmlXPathRegisterNs
does not accept a NULL prefix argument, so it is not possible to override the behaviour such that the p element will be returned. And even if it did it seems that there are NULL checks for prefix in the querying code of XPath.
Is there something I'm missing, or is this a feature that's not supported right now? Thanks in advance