How to control root node name for the DataTable.WriteXML method ca

G

Guest

I am trying to leverage ADO.NET 2.0 DataTable WriteXML method and serialize
datatable as an XML file..

dataTable.WriteXml(xmlFile)

Unfortunately, root node of the output file is always DocumentElement. Is
there way to control the name of the root node for the XML output?
 
R

Robbe Morris [C# MVP]

Haven't looked at that yet but what happens when
you programmatically/manually define the table name
in the DataTable class?
 
Y

Yitzhak

Table name creates a placeholder for each row in the resultset.
Root name still stays named as a DocumentElement.
So you will get something like this:
<DocumentElement>
<TableName>
<column1> </column1>
<column2> </column2>
etc.
</TableName>
<TableName>
<column1> </column1>
<column2> </column2>
etc.
</TableName>
</DocumentElement>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top