by
3,709 13
0
4
389
1
Top 5% !
Popular
Specified
OpenSource
No tags for this snippet yet.
LanguageCSharp

Datatable to XML

Converting a datatable (or dataset) to XML
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/2976239/Datatable-to-XML?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
//To go to a string string result; using (StringWriter sw = new StringWriter()) { dataTable.WriteXml(sw); result = sw.ToString(); } //To go to memory stream and XPath document XPathDocument result; using (MemoryStream ms = new MemoryStream()) { dataTable.WriteXml(ms); ms.Position = 0; result = new XPathDocument(ms); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus