Visual Studio 2010 / SQL server 2008
I have two tables for parent xml and child xml and they are related by key.
I am trying to generate a XML string by using Linq(or anything works) and those two tables.
Parent xml data : Country
Child xml data : USA, Mexico
I want to generate it like this way.
<Country>
<USA>
</USA>
<Mexico>
</Mexico>
</Country>
I have been tried with few ways but I could not figure out.
Does anybody has suggestion?
Thanks.
The
WriteXmlmethod from theDataSetclass should get you pretty close to what you want, and it’s a simple thing to do.In C#, it’s:
So all you have to do is load up your
DataSetwith the appropriate data, and theWriteXmlmethod should generate a fairly appropriate XML representation of that data.