Home All Groups Group Topic Archive Search About

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

Author
18 Nov 2005 4:18 PM
Yitzhak
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?

Author
21 Nov 2005 11:24 PM
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?

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.masterado.net





Show quote
"Yitzhak" <Yitz***@discussions.microsoft.com> wrote in message
news:956AFA96-52FF-4E1E-825A-E15EF85165CC@microsoft.com...
>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?
>
Author
22 Nov 2005 5:09 PM
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>

Show quote
"Robbe Morris [C# MVP]" <i***@eggheadcafe.com> wrote in message
news:%23iCIUJv7FHA.1248@TK2MSFTNGP14.phx.gbl...
> Haven't looked at that yet but what happens when
> you programmatically/manually define the table name
> in the DataTable class?
>
> --
> Robbe Morris - 2004/2005 Microsoft MVP C#
> http://www.masterado.net
>
>
>
>
>
> "Yitzhak" <Yitz***@discussions.microsoft.com> wrote in message
> news:956AFA96-52FF-4E1E-825A-E15EF85165CC@microsoft.com...
>>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?
>>
>
>

AddThis Social Bookmark Button