Please Help on ReadXml()

J

John

I use dataSet.ReadXml(xmlFileName) to read in the following xml file:
<Factory>
<Group Name="Group1" />
</Factory>

After read it in, in the debug window, it tells me that there are two rows
in the table instead of one which is correct. Then I call
dataSet.WriteXml(xmlFileName) and the xml file becomes the following,

<Factory>
<Group Name="Group1" />
<Group Name="Group1" />
</Factory>

What is wrong with my code/xml schema? Please help. Thanks.
 
M

Martin Honnen

John said:
I use dataSet.ReadXml(xmlFileName) to read in the following xml file:
<Factory>
<Group Name="Group1" />
</Factory>

After read it in, in the debug window, it tells me that there are two rows
in the table instead of one which is correct. Then I call
dataSet.WriteXml(xmlFileName) and the xml file becomes the following,

<Factory>
<Group Name="Group1" />
<Group Name="Group1" />
</Factory>

What is wrong with my code/xml schema? Please help. Thanks.

Do you have a schema at all? How does it look? Do you read it in with
ReadXmlSchema before reading in the data with ReadXml?
 
J

John

I don't have a schema.

Martin Honnen said:
Do you have a schema at all? How does it look? Do you read it in with
ReadXmlSchema before reading in the data with ReadXml?
 
M

Martin Honnen

John said:
I don't have a schema.

I can't reproduce the problem. Testing with .NET 3.5 SP1 where
XMLFile1.xml has the contents
<?xml version="1.0" encoding="utf-8" ?>
<Factory>
<Group Name="Group1" />
</Factory>
the code

DataSet ds = new DataSet();
ds.ReadXml(@"..\..\XMLFile1.xml");

ds.WriteXml(Console.Out);

outputs

<Factory>
<Group Name="Group1" />
</Factory>
 

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