Nescio
Nescio

Reputation: 28433

How to convert an XML file into a .Net class?

Can someone please remind me how to create a .Net class from an XML file?

I would prefer the batch commands, or a way to integrate it into the shell.

Thanks!

Upvotes: 2

Views: 1002

Answers (2)

Nescio
Nescio

Reputation: 28433

The below batch will create a .Net Class from XML in the current directory.
So... XML -> XSD -> VB

(Feel free to substitute CS for Language)

Create a Convert2Class.Bat in the %UserProfile%\SendTo directory.
Then copy/save the below:

@Echo off
Set XsdExePath="C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\XSD.exe"
Set Language=VB
%~d1
CD %~d1%~p1 
%XsdExePath% "%~n1.xml" /nologo
%XsdExePath% "%~n1.xsd" /nologo /c /language:%Language%

Works on my machine - Good Luck!!

Upvotes: 2

Quintin Robinson
Quintin Robinson

Reputation: 82375

You might be able to use the xsd.exe tool to generate a class, otherwise you probably have to implement a custom solution against your XML

XML Schema Definition Tool

XML Serialization

Upvotes: 0

Related Questions