How to get DataTable to serialize better?
Posted
by AngryHacker
on Stack Overflow
See other posts from Stack Overflow
or by AngryHacker
Published on 2010-04-14T19:13:27Z
Indexed on
2010/04/14
19:53 UTC
Read the original article
Hit count: 332
I have the following code that serializes a DataTable to XML.
StringWriter sw = new StringWriter();
myDataTable.WriteXml(sw);
And this works, however, the serialized XML looks like this:
<NameOfTable>
<NameOfTable>
<ID>1</ID>
<Name>Jack</Name>
</NameOfTable>
<NameOfTable>
<ID>2</ID>
<Name>Frank</Name>
</NameOfTable>
</NameOfTable>
Is there anyway to change the outer <NameOfTable>
to, say, <Records>
and the inner <NameOfTable>
to <Person>
?
© Stack Overflow or respective owner