seeking help reading xml into a dataset

K

konsu

hello,

would xml/ado.net experts please help me:

i have two sql tables (to store RSS feeds, but it is not important):

create table channels (id uniqueidentifier not null default newid() primary
key,
title nchar(256) null,
url ntext null)

create table items (id uniqueidentifier not null default newid() primary
key,
cid uniqueidentifier not null references channels(id),
title ntext null,
url ntext null,
descr ntext null)

RSS feeds usually come in XML like this:

<?xml version="1.0" ?>
<rss version="0.91">
<channel>
<title>...</title>
<link>...</link>
<description>...</description>
<item>
<title>...</title>
<link>...</link>
<description>...</description>
</item>
<item>
<title>...</title>
<link>...</link>
<description>...</description>
</item>
</channel>
</rss>

so, a channel can contain zero or more items.

i would like to read xml data into a DataSet object using DataSet.ReadXml(),
and save it into the above database tables using DataAdapter.Update().

the problem that i am trying to solve currently is that the schema of the
above xml does not match the schema of a dataset containing these two
tables, so nothing gets saved to the database. is there a way to tell
DataSet to read the given xml and convert the data to conform to another
schema?

would appreciate any input

konst
 
M

Mike Smith

dont know if its much help but the readXML does have the
XmlReadMode.IgnoreSchema or maybe even the InferSchema so it can basically
guess its own schema from the data. Else if you want to comply to a specific
format from another you will have to use the xslTransform object to convert
it from one form to another....
 

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

Similar Threads


Top