i have a table with hierarchical structure. like this:

(source: aspalliance.com)
and table data shown here:

(source: aspalliance.com)
this strategy gives me the ability to have unbounded categories and sub-categories.
i use ASP.net 3.5 SP1 and LINQ and MSSQL Server2005. How to convert it to XML? I can Do it with Dataset Object and “.GetXML()” 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.
Question Update
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:
<siteMapNode url="~/Category?cid=0" title="Home" description="Home">
<siteMapNode url="~/Category?cid=1" title="a" description="" />
<siteMapNode url="~/Category?cid=2" title="b" description="" >
<siteMapNode url="~/Category?cid=3" title="c" description="" />
<siteMapNode url="~/Category?cid=4" title="d" description="" />
</siteMapNode>
</siteMapNode>
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?
Ok very quickly (and thoroughly untested).
To “roll your own” XML using Linq to SQL and Linq to XML (which are generic .NET not ASP.NET specific) is fairly simple, this should be sufficient given a few assumptions which I’ll detail after (now modified slightly as suggested):
Ok, from the top
from m in menu.ChildMenus select GetMenuXML(m)If it works (!) you should get XML something like