dataSet.ReadXML returns more tables than it should - HELP!!!

  • Thread starter Thread starter nish
  • Start date Start date
N

nish

hi,

so i have an xml file as follows:

<Employees>
<name>
<empName>nisha</empName>
<state>NJ</state>
</name>
<name>
<empName>dave</empName>
<state>California</state>
</name>
</Employees>


When i execute the follwing code:

DataSet ds = new DataSet("employees");
ds.ReadXML("employees.xml");


The ds.Tables.count = 2. i need the "employees" as a table only,
resulting in just 1 Table and 2 rows. I am looking for a parent child
relationship in the dataset. Can someone please help me out with this
code. I am not sure if I need to use XmlReadMode.Infer - but any
assistance would be great.

Thanks so much.
Nisha
 
You will have to preform some sort transformation on the Xml before giving
to the DataSet. The inference rules do not allow for the mapping you want.
In fact, I believe if that even if an explicit XSD is provided, there is no
way to get that shape into a single table.

Andrew Conrad
Microsoft Corp
http://blogs.msdn.com/aconrad/
 
Back
Top