title: how to convert Database Hierarchical Data to XML using ASP.net 3.5 and LINQ
body: <p>i have a table with hierarchical structure. like this:<br/>
  <a href="https://i.stack.imgur.com/JmDpf.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JmDpf.gif" alt="alt text"></a><br>
  <sub>(source: <a href="http://aspalliance.com/ArticleFiles/822/image002.gif" rel="nofollow noreferrer">aspalliance.com</a>)</sub>  </p>
  
  <p>and table data shown here:<br/>
  <a href="https://i.stack.imgur.com/Tattz.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tattz.gif" alt="alt text"></a><br>
  <sub>(source: <a href="http://aspalliance.com/ArticleFiles/822/image003.gif" rel="nofollow noreferrer">aspalliance.com</a>)</sub>  </p>
  
  <p><br/>
  this strategy gives me the ability to have unbounded categories and sub-categories. <br/><br/>
  i use ASP.net 3.5 SP1 and LINQ and MSSQL Server2005. <strong>How to convert it to XML?</strong> I can Do it with <em>Dataset Object</em> and "<em>.GetXML()</em>" method. but how to implement it with LINQtoSQL or LINQtoXML??? or if there is another simpler way to perform that? what is your suggestion? the best way? I searched the web but found nothing for .net 3.5 featuers.
  <br/><br/>
  <strong>Question Update</strong><br/>
  thnks to Murph but Now I have a New Problem. I want to Make a Dunamic SiteMap file in my Project. You Know the SiteMap file in ASP.net looks like this:
  
  </p>
  
  <pre><code>&lt;siteMapNode url="~/Category?cid=0" title="Home"  description="Home"&gt;
  
      &lt;siteMapNode url="~/Category?cid=1" title="a"  description="" /&gt;
  
      &lt;siteMapNode url="~/Category?cid=2" title="b"  description="" &gt;
  
          &lt;siteMapNode url="~/Category?cid=3" title="c"  description="" /&gt;
  
          &lt;siteMapNode url="~/Category?cid=4" title="d"  description="" /&gt;
  
      &lt;/siteMapNode&gt;
  &lt;/siteMapNode&gt;
  </code></pre>
  
  <p></p>
  
  <p>Main Problem is that according to Mr.Murph's Code the sub categories will nested in  element. but in SiteMap Case we have no such a elements and all of categories and sub categories are nested in  elements. how can I change Mr.Murph code to shape this Schema?</p>