I followed this SO answer to turn the below xml structure into a dataset.
<?xml version="1.0" encoding="UTF-8"?>
<data>
<child1>
<to>alice@mail.com</to>
<from>bob@mail.com</from>
<name>alice alicia</name>
</child1>
<child2>
<file>
<size>123</size>
<content>lorem ipsum</content>
</file>
</child2>
</data>
It turned into 3 tables in the dataset:
- child1 table with 3 columns (to,from,name).
- child2 table with 1 columns (file).
- file table with 2 columns (size,content).
At the end, I want to have only 1 table with 5 columns (to,from,name,size,content).
Could I use a schema to design the way ReadXml in DataSet interprets the xml into my desired table? And if so, how would such schema look like?
I thought of 2 more solutions, though I less prefer them because they require manual handling, which I believe are costly when handling many xmls:
- Changing the data set after reading xml, consolidating the 3 tables into one and removing the unneeded column (file).
- Editing the xml manually before calling ReadXml method in DataSet.