title: Date elements in XML
body: <p>I guess there are two major approaches to date representations in XML:</p>
  
  <pre><code>&lt;date&gt;1984-10-27&lt;/date&gt;
  </code></pre>
  
  <p>and </p>
  
  <pre><code>&lt;date&gt;
    &lt;year&gt;1984&lt;/year&gt;
    &lt;month&gt;10&lt;/month&gt;
    &lt;day&gt;27&lt;/day&gt;
  &lt;/date&gt;
  </code></pre>
  
  <p>Personally I would go for the former. It's more compact and at the same time more readable. The split-up of the second form seems overkill to me; e.g. most of the time the month in itself will have no information value.</p>
  
  <p>Also you can't validate an element like &lt;day&gt; independently: you can define a range of [1..31], but 31 isn't acceptable if &lt;month&gt; is 2.</p>
  
  <p>On the other hand the first form could cause confusion, especially if you use (FFF) MM-DD-YYYY or DD-MM-YYYY.  I always use ISO 8601 format (YYYY-MM-DD), as it avoids this confusion.</p>
  
  <p>Which XML code do you prefer?</p>