Solved

XML file to a usable data class in Visual Studios.

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 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