How to read XML into a dataset?

I have a XML xsd defined. There are header, details, and EXTRINSIC  data element in the schema How do I read the XML data into a dataset? I can, of course, define different tables in the dataset to model the header and details.

Platform and Env: ASP.NET 2.0, C# and SQL 2005. VS.NET 2005
Who is Participating?
vbturboConnect With a Mentor Commented:

a small sample.  Which takes the assumption that a xsd is created.

       Dim testing As New DataSet

        ' Load the prototype XSD file...

        ' Receiving a file based upon that schema...

        ' Writing an xml file based upon that schema...
            'save the schema

And a couple of other tips in this regard

Generating DataSet Relations from XML Schema (XSD)

Mapping XML Schema (XSD) Constraints to DataSet Constraints

Create a DataRelation to link the two tables

manage Constraints

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

chuang4630Author Commented:
Thanks for the example. However, the sample file only shows how to load the data into a untyped dataset (based upon the schema). How to load the XML into a typed dataset?
May be I'm missing something.. What do you call typed dataset? For me if schema is loaded it provides the dataset with types stored.
Well it would help if we know what you are trying to implement.
chuang4630Author Commented:
Here are what I have and what I need to achieve:
(1) I have a XML data string. It consists three parts: LOGIN, ASSETHEADER and ASSETSITEMS.
(2) The XML schema is predefined (MySchema.xsd) in MyProjectCommon
(3) I need to populate part of the XML data into the database table TempAssets.

I can ReadXML to the generic DataSet and process the data from there. However, due to the nature of the generic dataset, I have to reference the data column through row["PONUMBER"]. And there is no relationship between the tables in the dataset.

What I am thinking about is to predefine a dataset that models after the schema. Load the XML data string to this dataset. So I can utilize typed dataset feature to manipulate data.
Also, I try to avoid to read the schema fom file system (I/O) and prefer the reference. Otherwise I have provide the filepath and heavily access the disk I/O.

How do I achieve that?

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.