XML question

Started by
3 comments, last by Alpha_ProgDes 17 years, 10 months ago
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!
Advertisement
I prefer not to use attributes, but that's just me. You can read more at w3schools.com, just click XML to the left.
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.
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!
Honestly, I would use attributes for values that don't change or hardly change. Otherwise nested elements for "variable" values.

Beginner in Game Development?  Read here. And read here.

 

This topic is closed to new replies.

Advertisement