[severity:It's more difficult to complete my work]
When XML contains data representing non-existing tables, this data is not ignored, but instead loaded into existing table if the name of the column is the same.
Reproducer:
using System.Data;
using System.Xml;
DataTable table = new DataTable("table");
table. Columns.Add("column1");
table. Columns.Add("column2");
DataSet ds = new DataSet();
ds. Tables.Add(table);
string xml = @"
<table>
column2_data
not_existing_table_data
column1_data
</table>
";
XmlReader reader = XmlReader.Create(new StringReader(xml));
ds. ReadXml(reader);
Console.WriteLine(ds. GetXml());
From the docs:
IgnoreSchema
Ignores any inline schema and reads data into the existing DataSet schema. If any data does not match the existing schema, it is discarded (including data from differing namespaces defined for the DataSet). If the data is a DiffGram, IgnoreSchema has the same functionality as DiffGram.
Tagging subscribers to this area: @roji, @ajcvickers
See info in area-owners.md if you want to be subscribed.
Issue Details
_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/DataSetReadXml-reads-data-from-incorrec/10246283)._
---
[severity:It's more difficult to complete my work]
When XML contains data representing non-existing tables, this data is not ignored, but instead loaded into existing table if the name of the column is the same.
Reproducer:
```
using System.Data;
using System.Xml;
DataTable table = new DataTable("table");
table. Columns.Add("column1");
table. Columns.Add("column2");
DataSet ds = new DataSet();
ds. Tables.Add(table);
string xml = @"
column2_data
not_existing_table_data
column1_data
";
XmlReader reader = XmlReader.Create(new StringReader(xml));
ds. ReadXml(reader);
Console.WriteLine(ds. GetXml());
```
Actual output is:
```
not_existing_table_data
column2_data
```
Expected output is:
```
column1_data
column2_data
```
From the docs:
IgnoreSchema
Ignores any inline schema and reads data into the existing DataSet schema. **If any data does not match the existing schema, it is discarded** (including data from differing namespaces defined for the DataSet). If the data is a DiffGram, IgnoreSchema has the same functionality as DiffGram.
---
### Original Comments
#### Feedback Bot on 1/6/2023, 02:34 AM:
(private comment, text removed)
---
### Original Solutions
(no solutions)
This issue has been moved from a ticket on Developer Community.
[severity:It's more difficult to complete my work] When XML contains data representing non-existing tables, this data is not ignored, but instead loaded into existing table if the name of the column is the same.
Reproducer:
Actual output is:
Expected output is:
From the docs: IgnoreSchema Ignores any inline schema and reads data into the existing DataSet schema. If any data does not match the existing schema, it is discarded (including data from differing namespaces defined for the DataSet). If the data is a DiffGram, IgnoreSchema has the same functionality as DiffGram.
Original Comments
Feedback Bot on 1/6/2023, 02:34 AM:
(private comment, text removed)
Original Solutions
(no solutions)