I’m using XML for a config file in PHP (Using SimpleXML), in creating the config file what is more of a standard.
Having all values in elements or using the attributes?
Elements Example:
<database>
<user>test-user</user>
<pass>test-pass</pass>
</database>
Attribute Example:
<database user="test-user" pass="test-pass"></database>
Are there any benefits of either way?
Also other languages might need to read the same config file, such as Java and Perl.
See Principles of XML design: When to use elements versus attributes by IBM. Pretty nice article.
Here’s a snippet:
In my experience working with users of XML, the first question is by far the most common. In some cases the answer is pretty unambiguous: