Is there a standard naming convention for XML elem

2019-01-10 16:09发布

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"/>

13条回答
We Are One
2楼-- · 2019-01-10 16:47

I would tend to favour lowercase or camelcase tags and since attributes should typically reflect data values - not content - I would stick to a value which could be used as a variable name in whatever platform/language might be interested, i.e. avoid spaces but the other two forms could be ok

查看更多
登录 后发表回答