Solved

XML file to a usable data class in Visual Studios.

Posted on 2013-06-12
3
287 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 75

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 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

17 Experts available now in Live!

Get 1:1 Help Now