ReadXml into a DataTable?

G

Guest

Hi,

I've gotten the dataset.ReadXml() method to load XML from a remote source
but I was wondering since I plan on having multiple datatables in the
dataset, can you specify which table to read XML into? I'm using ASP.NET 1.1

Thanks, Dave
 
W

W.G. Ryan eMVP

Using the 1.1 framework I don't believe that there is - however the way the
XML document is structured will control how it's loaded. As such, you have
two alternatives that come to mind off of the top of my head. 1) If you can
control the XML you are reading, you can manipulate to load into whatever
table(s) you want 2) If you can't control the XML document, you could use an
XSLT Translation to take your XML, and get it in a format that will load
into the tables you want it to - from there you can just use ReadXML like
you normally would. I'll look around and see if there's another way but I
don't recall seeing any table mappings. Fortunately in the near future
there's going to be full XML support for DataTables under the 2.0 framework
but that doesn't solve anything for you until then.

Cheers,

Bill
 
G

Guest

Thanks, but I guess I don't understand the part "if you can control the XML
you are reading, you can manipulate it to load into whatever table(s) you
want ". I'm not sure how the ReadXml know which of the 3 datatables I want
to load it into if I create tables like....

DataTable dtOne = new DataTable();
dst.Tables.Add(dtOne);
etc..

Thanks again. Dave.
 
A

Alex Passos

You can always read the new data into a separate DataSet and perform a merge
operation on a single table.

Alex
 
S

Sahil Malik [MVP]

Yeah that'll work too. But Merge is expensive, and tricky - it takes a lot
of decisions internally based on schemas, so it might work, but you can also
row a boat to Japan - just not the best way to get there.

- Sahil Malik [MVP]
http://codebetter.com/blogs/sahil.malik/
 

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