Convert XML to Data Transferable C# object

Hi,

Can someone please help me to convert attached XML file into Data Transferable C# object?

Thanks,
Ravikiran.T
student.xml
mynetquestionsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CuteBugCommented:
I think you are referring to Data Transfer Object.

Check this link
0
Fernando SotoRetiredCommented:
It will depend on how you plan to transfer the object to the other end. What technology are you planning to use to transmit the XML document to the other end.
0
mynetquestionsAuthor Commented:
I want to load all data into one single table. Each Student Result should be stored as separate row in the database
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Fernando SotoRetiredCommented:
First the XML document you posted is not a Well Formed XML document, for example the root node does not have a closing tag.

Does this XML represent one or more students?
What nodes in the XML document maps to the columns in the database?
What database MS-SQL, Oracle, MySQL server are you using?
0
dameyCommented:
Use the xsd.exe.
If you have visual studio you'll have the xsd.exe utility.
If not you can download just the utility:
http://juliankay.com/development/download-xsd-exe/

Go to the command line and use the xml file you want to generate a classe with.
Great easy utility to use and it can do much more.

SAMPLE:

D:\temp>xsd test.xml


Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'D:\temp\test.xsd'.

D:\temp>xsd test.xsd /classes
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'D:\temp\test.cs'.
0
mynetquestionsAuthor Commented:
Hi Fernando,

I have attached Well formatted XML document again.

Below are the answers for your questions.

Does this XML represent one or more students?--Only One Student with multiple "Accession_NUMBER" with multiple test results.

What nodes in the XML document maps to the columns in the database?--All Nodes
What database MS-SQL, Oracle, MySQL server are you using?--We are using Oracle
student.xml
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dameyCommented:
I thought you wanted to generate C# class from xml file.

If you want to insert the file to existing table and as long as the order in xml is has the same column order you can bulk insert in sql server using the folowing syntax:

INSERT INTO T(XmlCol)
SELECT * FROM OPENROWSET(
   BULK 'c:\SampleFolder\SampleData3.txt',
   SINGLE_BLOB) AS x;

Here is a tutorial on more options for single rows.
https://www.mssqltips.com/sqlservertip/2118/scripts-to-use-xml-to-insert-and-update-rows-in-a-sql-server-table/
0
Fernando SotoRetiredCommented:
I agree with @damey on this.
0
mynetquestionsAuthor Commented:
This is helpful. I have used xsd.exe to generate the class and used to deserialize the XML data.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

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.