8000 Better informal support for namespaces · Issue #656 · zeux/pugixml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Better informal support for namespaces #656
Open
@KaruroChori

Description

@KaruroChori

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0