Sign in to follow this  
Replicon

XML question

Recommended Posts

I have almost zero experience with XML, and was wondering if there's a good place to find good design guidelines for it. I'm playing with TinyXML, and am thinking of storing my config files in XML format in my current project, so as to avoid having to write yet another parser. I'm just interested in random design guidelines, like when is it good to do this:
<Difficulty val="easy" />
as opposed to this:
<Difficulty>easy</Difficulty>
and so on and so forth. cheers!

Share this post


Link to post
Share on other sites
I prefer not to use attributes, but that's just me. You can read more at w3schools.com, just click XML to the left.

Share this post


Link to post
Share on other sites
Attributes have to be uniquely named per node so

<game difficulty="high"/>

would be preferable as

<game difficulty="low" difficulty="high"/>

would not be well-formed.

whereas
<game>
<difficulty>high</difficulty>
<difficulty>low</difficulty>
</game>

isn't obviously wrong.

Share this post


Link to post
Share on other sites
Ah, the W3Schools had quick and useful information on the matter. They seem to prefer nested elements to attributes. I think that will make my stuff easier to write too. I'll save attributes for more complex things, or things that can be globally applicable.

cheers!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this