title: Converting DataSet into XML with nested elements
body: <p>I am writing a WebService that is supposed to convert DataSet into XML. My DataSet is actually list of hotels with categories. Each hotel can belong to one or more categories.
  I followed an example from <a href="http://msdn.microsoft.com/en-us/library/7sfkwf9s%28v=vs.71%29.aspx#Y650" rel="nofollow">HERE</a> and it works well except I don't get result that I would like.</p>
  
  <p>This is what I get: (example 1)</p>
  
  <pre><code>&lt;hotels&gt;
      &lt;hotel&gt;
          &lt;name&gt;Hilton Resort&lt;/name&gt;
          &lt;category&gt;
              &lt;catname&gt;Hotel&lt;/catname&gt;
          &lt;/category&gt;
          &lt;category&gt;
              &lt;catname&gt;Resort&lt;/catname&gt;
          &lt;/category&gt;
          &lt;category&gt;
              &lt;catname&gt;Golf &amp; Spa&lt;/catname&gt;
          &lt;/category&gt;
      &lt;/hotel&gt; 
      &lt;hotel&gt;
          &lt;name&gt;Hyatt&lt;/name&gt;
          &lt;category&gt;
              &lt;catname&gt;Resort&lt;/catname&gt;
          &lt;/category&gt;
          &lt;category&gt;
              &lt;catname&gt;Golf &amp; Spa&lt;/catname&gt;
          &lt;/category&gt;
      &lt;/hotel&gt; 
  &lt;/hotel&gt;
  </code></pre>
  
  <p>but, I would like to get something like this: (example 2)</p>
  
  <pre><code>&lt;hotels&gt;
      &lt;hotel&gt;
          &lt;name&gt;Hilton Resort&lt;/name&gt;
          &lt;categories&gt;  
              &lt;catname&gt;Hotel&lt;/catname&gt;
              &lt;catname&gt;Resort&lt;/catname&gt;
              &lt;catname&gt;Golf &amp; Spa&lt;/catname&gt;
          &lt;/categories&gt;
      &lt;/hotel&gt; 
      &lt;hotel&gt;
          &lt;name&gt;Hyatt&lt;/name&gt;
          &lt;categories&gt;  
              &lt;catname&gt;Hotel&lt;/catname&gt;
              &lt;catname&gt;Golf &amp; Spa&lt;/catname&gt;
          &lt;/categories&gt;
      &lt;/hotel&gt; 
  &lt;/hotel&gt;
  </code></pre>
  
  <p>Here is my current code that produces XML as in example 1:</p>
  
  <pre><code>        ...
          ...
          SqlDataAdapter hotelDA = new SqlDataAdapter(SQLHotels, SQLConn);
          SqlDataAdapter catDA = new SqlDataAdapter(SQLCats, SQLConn);
  
          DataSet ds = new DataSet("Hotels");
  
          hotelDA.Fill(ds, "Hotel");
          catDA.Fill(ds, "Category");
  
          DataRelation SleepRel = ds.Relations.Add("Hotel",
                   ds.Tables["Sleep"].Columns["Id"],
                   ds.Tables["Category"].Columns["AccID"]);
          SleepRel.Nested = true;
          SQLConn.Close();
          return ds;
  </code></pre>
  
  <p><strong>SQLHotels</strong> - SQL SELECT statement that selects all hotels<br>
  <strong>SQLCats</strong> - SQL SELECT statement that selects all categories<br>
  <strong>Id</strong> - hotel ID<br>
  <strong>AccId</strong> - hotel ID in table Category (foreign key)</p>
  
  <p>My questions:<br>
  <strong>1) Does it actually matter? Is one structure better then another one?<br>
  2) Is it possible to make relation between two tables in DataSet so I get output like it is in second (desired) XML example.</strong></p>