title: XML string to DataTable object c# method - advice needed
body: <p>In ASP.NET application I have a query onto sql database for some data and one part of the data is XML string. I want to "convert" this XML string into DataTable object once retrieved into ASP.NET application.</p>
  
  <p>I have SQL query which select all feeds (their titles, descriptions) from Feeds table and additional data from related tables (in this case tags of feeds). I retrieve additional data in XML string (I achieve this using <code>FOR XML PATH('')</code> in sql):</p>
  
  <pre><code>SELECT
      F.ID, F.Title, F.Text,
      (SELECT
         T.TagID, T.TagName
      FROM
         sn.Tag AS T
      INNER JOIN
         sn.FeedTag AS FT ON FT.TagID = T.TagID
      WHERE
         FT.FeedID = F.FeedID
      FOR
         XML PATH('tag')
      ) 
      AS FeedTagsXML
  FROM
      sn.Feed AS F
  WHERE 
      F.ID = 12876
  </code></pre>
  
  <p>And the XML result of this query is (value of <code>FeedTagsXML</code> column):</p>
  
  <pre><code>&lt;tag&gt;
    &lt;TagID&gt;114&lt;/TagID&gt;
    &lt;TagName&gt;Test 1&lt;/TagName&gt;
  &lt;/tag&gt;
  &lt;tag&gt;
    &lt;TagID&gt;115&lt;/TagID&gt;
    &lt;TagName&gt;Test 2&lt;/TagName&gt;
  &lt;/tag&gt;
  &lt;tag&gt;
    &lt;TagID&gt;116&lt;/TagID&gt;
    &lt;TagName&gt;test 3&lt;/TagName&gt;
  &lt;/tag&gt;
  &lt;tag&gt;
    &lt;TagID&gt;117&lt;/TagID&gt;
    &lt;TagName&gt;Test 4&lt;/TagName&gt;
  &lt;/tag&gt;
  </code></pre>
  
  <p>Now all I need is to convert this string into DataTable object. Currently I have a method which returns DataTable for this xml string:</p>
  
  <pre><code>public DataTable GetDataTableFromXML(string xmlStringForDataTable)
  {
      //read into dataset
      DataSet dataSet = new DataSet();
      xmlStringForDataTable = "&lt;items&gt;" + xmlStringForDataTable+ "&lt;/items&gt;";
      dataSet.ReadXml(new StringReader(xmlStringForDataTable));
      DataTable dt = new DataTable();
      //return single table inside of dataset
      if (dataSet.Tables.Count &gt; 0)
      {
         dt = dataSet.Tables[0];
      }
      return dt;
  } 
  </code></pre>
  
  <p>This approach kinda works but I am sure there are better solutions than this. One of the things I don't like for example is appending additional root element to whole string to be able to convert it (if I don't do this whole method fails) and also using DataSet for simple DataTable. How could I improve this method / is there some way (I don't know about yet) to convert xml string to DataTable C# object in a much cleaner way?</p>