Is there a standard naming convention for XML elements?

tpower picture tpower · Jan 14, 2009 · Viewed 63.3k times · Source

Is there any standard, de facto or otherwise, for XML documents? For example which is the "best" way to write a tag?

<MyTag />
<myTag />
<mytag />
<my-tag />
<my_tag />

Likewise if I have an enumerated value for an attribute which is better

<myTag attribute="value one"/>
<myTag attribute="ValueOne"/>
<myTag attribute="value-one"/>

Answer

Marc Gravell picture Marc Gravell · Jan 14, 2009

I suspect the most common values would be camelCased - i.e.

<myTag someAttribute="someValue"/>

In particular, the spaces cause a few glitches if mixed with code-generators (i.e. to [de]serialize xml to objects), since not many languages allow enums with spaces (demanding a mapping between the two).