I find that it's very rare that I care about the difference between a missing and a blank attribute.
I would favour adding a HasAttribute() function for the few times one needs to check and changing the return from ->Attribute() to be an empty string.
I think this would reduce the amount of code one needed to write for most operations, but I may be wrong.
comments anyone?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is really a style thing, I suspect, but I am used to xml parsers which return null strings when Attributes don't exist instead of NULL values.
With TinyXml one must write:
std::string somestring;
if (el->Attribute( "id" ))
somestring = el->Attribute( "id" );
instead of:
std::string somestring = el->Attribute( "id" );
(TinyXml gives exception if attribute 'id' doesn't exist )
I find that it's very rare that I care about the difference between a missing and a blank attribute.
I would favour adding a HasAttribute() function for the few times one needs to check and changing the return from ->Attribute() to be an empty string.
I think this would reduce the amount of code one needed to write for most operations, but I may be wrong.
comments anyone?