We help IT Professionals succeed at work.

How to read XML into a dataset?

chuang4630
chuang4630 asked
on
610 Views
Last Modified: 2013-11-26
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
Comment
Watch Question

Dmitry GSenior Developer
CERTIFIED EXPERT

Commented:

Author

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?
Dmitry GSenior Developer
CERTIFIED EXPERT

Commented:
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.

Author

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?


Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.