Solved

XML file to a usable data class in Visual Studios.

Posted on 2013-06-12
3
286 Views
Last Modified: 2013-06-17
I have a set of XML files that I need to use in C#.

Is there a way in Visual Studio to take an xml file and create a data class for it?  I would then use c# to load the xml file into the data class.

Hopefully that makes sense.
0
Comment
Question by:rye004
3 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 39243433
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 250 total points
ID: 39243566
u can do it using xsd.exe tool:
run this first:
/>xsd.exe file.xml

the output will be xsd file, then u run:
/>xsd.exe file.xsd /c

that will generate cs file which mapps the xml file.
the alternative is to do it manually by mapping the xml structure by class hierarchies.
@kaufmed has provided you links to help you do it.

FYI xsd.exe generates xml elements from System.Xml (.net 1.1) not system.xml.linq(.net 3.5),
that might affect your decision whether using the tool.
anyway, its pretty easy to make the modification to system.xml.linq xml types.
0
 

Author Closing Comment

by:rye004
ID: 39253744
Thank you so much for this.  It worked perfectly.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now