views:

44

answers:

0

Possible Duplicates:
XML Attributes vs Elements
Should I use Elements or Attributes in XML?

For tree leaves in XML, when is it better to use attributes, and when is it better to use descendant nodes?

For example, in the following XML document:

<?xml version="1.0" encoding="utf-8" ?>
<savedGame>
  <links>
    <link rootTagName="zombies" packageName="zombie" />
    <link rootTagName="ghosts" packageName="ghost" />
    <link rootTagName="players" packageName="player" />
    <link rootTagName="trees" packageName="tree" />
  </links>
  <locations>
    <zombies>
      <zombie>
        <positionX>41</positionX>
        <positionY>100</positionY>
      </zombie>
      <zombie>
        <positionX>55</positionX>
        <positionY>56</positionY>
      </zombie>
    </zombies>
    <ghosts>
      <ghost>
        <positionX>11</positionX>
        <positionY>90</positionY>
      </ghost>
    </ghosts>
  </locations>
</savedGame>

The <link> tag has attributes, but it could also be written as:

<link>
  <rootTagName>trees</rootTagName>
  <packageName>tree</packageName>
</link>

Similarly, the location tags could be written as:

<zombie positionX="55" positionY="56" />

instead of:

  <zombie>
    <positionX>55</positionX>
    <positionY>56</positionY>
  </zombie>

What reasons are there to prefer one over the other? Is it just a stylistic issue? Any performance considerations?

One possible consideration: my team will be using Visual Studio on this project, and the default syntax highlighting makes a chunk of tags with attributes more readable than a chunk of tags with inner text.