ReadXml for DataSet chokes if the root element has an attribute?

K

KJ

I have an easy xml document, for example:


<pics>
<pic name="foo"/>
<pic name="bar"/>
</pics>


I call ReadXML on my DataSet, and no problems (2 rows, one for each pic

element), one column for the name attribute.


However, if the Xml looks like this:


<pics attr="why">
<pic name="foo"/>
<pic name="bar"/>
</pics>


ReadXml only creates a 1 row table with the pics attribute "attr" as
its only column (ignoring the pic children).

So really, I have 2 questions:

Is it possible to control how ReadXml infers rows from Xml at runtime?

How to do so?

-TIA
 
D

Dmytro Lapshyn [MVP]

Hi KJ,

The detailed information on inferring DataSet schema from XML can be found
in the following MSDN topic:

"Inferring DataSet Relational Structure from XML" (.NET Framework
Developer's Guide)
 
K

KJ

Got it. Very helpful docs. I wasted half a day guessing at what the
rules were and tweaking the Xml. Now I know what ReadXml will do with
various Xml.
 

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

Top