Open MalcolmMcLean opened 5 years ago
You should consider that
<node xmlns:primer = "http://test/test">
<primer:value>val</primer:value>
</node>
and
<node xmlns:test = "http://test/test">
<test:value>val</test:value>
</node>
are equals ( namespace "http://test/test" + node name "value"). Prefixes are aliases to make documents shorter, you should check full namespace name.
I'd recommend to make perser code look like this:
XMLElement el = / intialise me */ if (el->equals("https://namespace/for/jim", "element")) { }
I'm adding namespace support to TinyXML2.
The way I'm planning to do it is this: you have three new user-exposed functions, XMLDocument::RegisterNamespace() and XMLElemement::Prefix() and XMLElement::LocalName().
By registering a namespace, you associate your own prefix with that namespace. A call to XMLElement::Prefix() then gives you your own prefix back, instead of the prefix used by the document author. LocalName() is just a trivial function which strips the prefix from the element's id.
So essentially parser code will look like this
Any comments anyone? Is this a good way to do it?