PC Review


Reply
Thread Tools Rate Thread

DataSet and XML problem

 
 
Amit Patankar
Guest
Posts: n/a
 
      10th Dec 2004
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.


 
Reply With Quote
 
 
 
 
Ilya Tumanov [MS]
Guest
Posts: n/a
 
      10th Dec 2004
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.
>
>
>


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataSet problem etam Microsoft ASP .NET 0 8th Jun 2007 01:16 AM
DataSet Problem Roshawn Microsoft ADO .NET 4 16th Jul 2004 07:48 PM
Dataset problem, please help pei_world Microsoft C# .NET 7 16th Feb 2004 12:33 AM
Problem updating existing typed dataset from Generate Dataset designer Eric Kennedy Microsoft ADO .NET 0 29th Aug 2003 05:55 PM
DataSet problem Shahar Microsoft C# .NET 1 11th Aug 2003 12:38 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:56 AM.