Dataset.WriteXml and xml:space="preserve"

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Why the method Dataset.WriteXml() produces xml with the attribute xml:space="preserve" in the elements containing empty strings?
Is there a way to avoid it? Here is an example :
- Define a dataset named DatasetTest in dataset designer, with one datatable named Table1. Add two datacolumns named Column1 and Column2 to the datatable. The datatype of both colums is string.

- Call this code snippet :

Dim ds As New DatasetTest
ds.Table1.AddTable1Row("value1", "")
ds.WriteXml("C:test.xml") - The result is : <?xml version="1.0" standalone="yes"?>
<DatasetTest xmlns=" http://tempuri.org/DatasetTest.xsd http://tempuri.org/DatasetTest.xsd http://tempuri.org/DatasetTest.xsd
<Table1>
<Column1>value1</Column1>
<Column2 xml:space="preserve" />
</Table1>
</DatasetTest>
This xml could non be validated by some applications, because of the attribute xml:space.

View the full article
 
Back
Top