Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

XML file to a usable data class in Visual Studios.

Posted on 2013-06-12
3
Medium Priority
?
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 42

Accepted Solution

by:
Meir Rivkin earned 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

604 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