Question about dataset readxml method

  • Thread starter Thread starter Raymond Du
  • Start date Start date
R

Raymond Du

Hi,

I am using Dataset's ReadXML method to read an XML file. Here i s my code
snippet:

Dim dsTemp As New DataSet
dsTemp.ReadXml(Server.MapPath("~/data3.xml"))

and data3.xml as follow:
<myDataSet>
<LeftMenu>
<MenuItem>
<Title>Enter Customer</Title>
<Action>Sid</Action>
</MenuItem>
<MenuItem>
<Title>Enter Contact</Title>
<Action>Sid</Action>
</MenuItem>
<MenuItem>
<Title>Enter City</Title>
<Action>Sid</Action>
</MenuItem>
<MenuItem>
<Title>Enter City</Title>
<Action>Sid</Action>
</MenuItem>
</LeftMenu>
</myDataSet>


After readXML statement, dsTemp.tables.count is 2, I am expecting only 1.
The one that has all XML content is dsTemp.tables(1), can any one explain
why there is another table?



TIA
 
Hi Ray,
This is exactly how the parsing happens in dataset.ReadXML method. Each
node with children will be added as a table to the dataset. So in your case
LeftMenu will be added as a table and then MenuItem table. If you check the
relationship (ds.Relations) you will find a parent-child relationship between
these two tables.

Hope this helps.

rgds,
Rakesh
 

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

Back
Top