Open
Description
It is clear that pugixml has no support for XML namespaces, but it is still desirable to use them even if in just some kind of lightweight manner.
One can simply assume they are specified as prefix of tags and attributes. I am doing just that in several of my projects.
However the current interface for child(...)
and attribute(...)
makes the process of working with these informal namespaces quite frustrating and not very ergonomic.
Basically, one is:
- either forced to build strings to have the
ns:
prefix for each affected name and use those functions with them.
This in general requires temporary string objects, which can be quite heavy on memory allocations for no good reason. - or to manually iterate over each element and perform two smaller string checks, basically replicating the internal functionality of the original functions.
This avoids the issue of memory allocations, at the cost of code clarity.
This issue could be easily mitigated by providing few more functions (and their string_view overloads) like ns_child
and ns_attribute
.
They would accept an extra first argument, which is informally interpreted as namespace.