<p>I'm creating an application that will store a hierarchical collection of items in an XML file and I'm wondering about the industry standard for storing collections in XML. Which of the following two formats is preferred? (If there is another option I'm not seeing, please advise.)</p>

<p><strong>Option A</strong></p>

<pre><code>&lt;School&gt;
    &lt;Student Name="Jack" /&gt;
    &lt;Student Name="Jill" /&gt;
    &lt;Class Name="English 101" /&gt;
    &lt;Class Name="Math 101" /&gt;
&lt;/School&gt;
</code></pre>

<p><strong>Option B</strong></p>

<pre><code>&lt;School&gt;
    &lt;Students&gt;
        &lt;Student Name="Jack" /&gt;
        &lt;Student Name="Jill" /&gt;
    &lt;/Students&gt;
    &lt;Classes&gt;
        &lt;Class Name="English 101" /&gt;
        &lt;Class Name="Math 101" /&gt;
    &lt;/Classes&gt;
&lt;/School&gt;
</code></pre>

[{'answer_id': 23067, 'author': 'Thomas Owens', 'author_id': 572, 'author_profile': 'https://Stackoverflow.com/users/572', 'pm_score': 3, 'selected': True, 'text': "<p>I'm no XML expert, but I find Option B to be more human readable, and I think it's just as machine readable as Option A. I believe that XML is designed to be both human and machine readable, so I would go for Option B myself.</p>\n\n<hr>\n\n<p>I just realized something else after Ryan Farley's post. If the Students or Classes section becomes too big and must be moved to another XML file, it seems like it would be easier to copy the node and create a new XML file out of that node with Option B.</p>\n"}, {'answer_id': 23071, 'author': 'Ryan Farley', 'author_id': 1627, 'author_profile': 'https://Stackoverflow.com/users/1627', 'pm_score': 2, 'selected': False, 'text': "<p><strong>Definitely - Option B.</strong>  </p>\n\n<p>I wouldn't mix students and classes in the XML just the same way that I wouldn't mix students and classes in the same table in a database.  </p>\n"}, {'answer_id': 23079, 'author': 'ceejayoz', 'author_id': 1902010, 'author_profile': 'https://Stackoverflow.com/users/1902010', 'pm_score': 2, 'selected': False, 'text': "<p><strong>Option B</strong>, absolutely. When there's a logical grouping of similar items, it should have a parent item.  That way, my parser won't have to step through all 500 student records checking to see if there are class records mixed in.</p>\n"}, {'answer_id': 23080, 'author': 'Jason Z', 'author_id': 2470, 'author_profile': 'https://Stackoverflow.com/users/2470', 'pm_score': 2, 'selected': False, 'text': '<p>Another compelling reason to use option B is error checking.  If the original file is modified outside an XML application, or if no XSD schema is applied, there could be the case where you have an uneven number of students and classes.</p>\n\n<p>At least if you have the students and classes grouped together, you will easily be able to tell if each record is complete, independently of any other record.</p>\n'}]
['https://Stackoverflow.com/questions/23064', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/317/']