DataSet.ReadXml and Empty Elements creating duplicate data

  • Thread starter Alejandro Calbazana
  • Start date
A

Alejandro Calbazana

Hello,

I am having trouble with the DataSet.ReadXml() method. While loading
a dataset containing empty elements having the same name as a parent
level node located elsewhere in my document, I noticed duplicate rows
in my newly loaded dataset (as well as duplicate elements when written
out to file).

My dataset resembles:

<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Test>
<Sample>1</Sample>
<Comments />
</Test>
<Comments>
<CommentID>13936</CommentID>
<CommentText>Test of comment area.</CommentText>
</Comments>
</NewDataSet>

After loading this into a DataSet, and writing out the "Comments"
DataTable to file I find this:

<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Comments/> <!-- huh??? -->
<Comments>
<CommentID>13936</CommentID>
<CommentText>Test of rent roll comment area.</CommentText>
</Comments>
</NewDataSet>

Note the extra empty Comments DataRow/Xml Element.

Is this a known issue with loading DataSets from Xml? What rules
should I conform to in order to load Xml into a DataSet properly?

This occurs with out without applying a schema before reading in the
xml. In fact, I ran into this while using an xsd as I could not
explain why the schema kept failing my xml load.

Any help is appreciated.

Thanks,

Alejandro
 

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