This is by design. DataSet XML saver has added DataSet tag which was
missing from your original XML.
That tag allows saving more than one row to the XML (your original XML only
allows for one row):
Wrong:
<Table> << First row in the Table
…
</Table>
<Table> << Second row in the Table - Can't be here as it would
create an invalid XML document.
…
</Table>
Correct:
<DataSet>
<Table> << First row in the Table
…
</Table>
<Table> << Second row in the Table
…
</Table>
</DataSet>
Note DataSet is not the XML storage, it's in memory database. It saves data
to XML in a very specific format.
The fact you can load some XML into the DataSet does not mean you'll get it
back the same way it was.
It only means data in the DataSet will be the same regardless of which file
you would load.
Consider using XmlDocument class which is in memory representation of the
XML instead if you need to keep XML exactly as it was.
Best regards,
Ilya
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
> From: "Amit Patankar" <(E-Mail Removed)>
> Subject: DataSet and XML problem
> Date: Fri, 10 Dec 2004 10:00:48 -0800
> Lines: 32
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
> X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
> Message-ID: <#pI#(E-Mail Removed)>
> Newsgroups: microsoft.public.dotnet.framework.compactframework
> NNTP-Posting-Host: 61.2.57.195
> Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
.phx.gbl
> Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.compactframework:66638
> X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
>
> Hi,
>
> I have an XML file having following format:
>
> <Table1>
> <Row1> Value </Row1>
> <Table2>
> <Row2>Value</Row2>
> </Table2>
> </Table1>
>
> I read this xml file and corresponding XSD file using dataset. But when I
> read the above xml file and rewrite the same contents, using WriteXML, i
> get an extra node at the top. So the new xml file looks like this:
>
> <Root>
> <Table1>
> <Row1> Value </Row1>
> <Table2>
> <Row2>Value</Row2>
> </Table2>
> </Table1>
> </Root>
>
> So an extra <Root> tag, which I found corresponds to the schema ID is
added,
> which is unwanted. I guess this should be the problem with the dataset.
> Could anyone suggest what I can do to avoid this extra node?
>
> Thanks a lot.
> Amit.
>
>
>
|