Jay Lash - 2009-03-06

My current project has strings from a text configuration file being used as element names in a XML tree.  I ran into an issue recently where there were some extra spaces at the end of the line in the config file.  This generated element names with trailing space, ex: <A   >xxx</A   >

TinyXML left the extra spaces in tact when it built the tree but had a problem when it tried to parse the tree.  It did okay with the start tag and the data but it failed to find the end tag.   In TiXmlElement::Parse() it uses ReadName() to get the tag name, which returns the tag name without the spaces.  That is fine for the start tag because there is additional processing to detect attributes which tolerate the spaces.  However, the end tag is built as "</" + name + ">" and used in a string compare with the input.  Obviously this fails.

My application has been modified to better validate the input, but there are two reasons for TinyXML to handle this scenario:  1) IMO, TinyXML should be able to parse anything that it builds, and more importantly 2) if I understand the XML grammar correctly trailing spaces in element names are valid.