Menu

#98 Attributes with the same name allowed or not?

closed-fixed
nobody
None
5
2010-03-14
2009-03-03
No

It's not clear if two element attributes with the same name are allowed or not.
On one side, there is no error set and even the value is changed to the new one, but on the other side the function is immediately aborted and the return code is 0 (i.e. failure if called from TiXmlElement::ReadValue()).
If attributes with the same name are allowed, the parser should continue with the remaining attributes.
Therefore, the return 0; command should be replaced by the continue; command.

Sourcecode:
// Handle the strange case of double attributes:
#ifdef TIXML_USE_STL
TiXmlAttribute* node = attributeSet.Find( attrib->NameTStr() );
#else
TiXmlAttribute* node = attributeSet.Find( attrib->Name() );
#endif
if ( node )
{
node->SetValue( attrib->Value() );
delete attrib;
return 0;
}

attributeSet.Add( attrib );
}

Discussion

  • Lee Thomason

    Lee Thomason - 2010-03-14

    Double attributes are now allowed in XML. Adding error handling.

     
  • Lee Thomason

    Lee Thomason - 2010-03-14
    • status: open --> closed-fixed
     

Log in to post a comment.