473,412 Members | 4,519 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

How to create a Class file from xml?

Anyone,
How can i use xsd.exe to create a class file to include in my c#
project? Is this the right program to use? Doing it by hand is a pain.
thanks,
BRAHM

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
5 5372
Hi Brahm:

From the command line you can run

XSD.exe /c schemafile.xsd

and it will produce a file with classes. Try xsd /? to see other
options available.

--
Scott
http://www.OdeToCode.com/

On Wed, 06 Oct 2004 10:54:34 -0700, Brahm <br***@arizona.org> wrote:
Anyone,
How can i use xsd.exe to create a class file to include in my c#
project? Is this the right program to use? Doing it by hand is a pain.
thanks,
BRAHM

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 16 '05 #2
Brahm,

In order to do this, you will need to have a schema for your XML. If
you don't have one, XSD.EXE can do that for you, by passing an instance of
the XML to the tool. You would call it like this:

xsd.exe file.xml

This will create an XSD file which has the schema. You can then reinput
the file into XSD.EXE and create a class:

xsd.exe file.xsd /classes /language:cs

You can specify things like namespace as well, through other options on
the tool, but this is pretty much how you do it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Brahm" <br***@arizona.org> wrote in message
news:u6**************@tk2msftngp13.phx.gbl...
Anyone,
How can i use xsd.exe to create a class file to include in my c#
project? Is this the right program to use? Doing it by hand is a pain.
thanks,
BRAHM

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #3
Instead of xsd.exe, consider using CodeSmith
http://www.ericjsmith.net/codesmith/

CodeSmith is a FREEWARE template-based code generator that can generate code
for any ASCII-based language. CodeSmith templates use a syntax nearly
identical to ASP.NET syntax so that creating templates should feel
immediately familiar to ASP.NET developers.

"Brahm" <br***@arizona.org> wrote in message
news:u6**************@tk2msftngp13.phx.gbl...
Anyone,
How can i use xsd.exe to create a class file to include in my c#
project? Is this the right program to use? Doing it by hand is a pain.
thanks,
BRAHM

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #4
Here is the xml file and i tried following your steps but it is giving
me error.
<?xml version="1.0" encoding="utf-8"?>
<EngineeringData xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
messageType="Started/NewData" xmlns="urn:engineering:xsd.FE">
<Context>
<CV pName="ID">
<S>MyID</S>
</CV>
<CV pName="duct">
<S>MyDuct</S>
</CV>
<CV pName="out">
<S>Mute</S>
</CV>
<CV pName="Operate">
<S>Mop</S>
</CV>
<CV pName="Op">
<S>MyOp</S>
</CV>
<CV pName="work">
<S>N</S>
</CV>
<CV pName="Type">
<S>SND</S>
</CV>
<CV pName="Too">
<S>XTWToo</S>
</CV>
<CV pName="Pipe">
<S>PhillipsPipe</S>
</CV>
<CV pName="ticle">
<S>1x30ybstr0ma1</S>
</CV>
<CV pName="ParameterSettings">
<Arr pName="Setting">
<S>hello</S>
<F4>30.1</F4>
</Arr>
</CV>
<CV pName="DNA">
<S>934082</S>
</CV>
<CV pName="Map">
<Arr pName="dMap">
<F4>32</F4>
<F4>33</F4>
<I4>12</I4>
<I4>12</I4>
</Arr>
</CV>
</Context>
<Data>
<DV pName="Sequence">
<I2>1</I2>
</DV>
<DV pName="Number">
<I2>5</I2>
</DV>
<DV pName="Trial">
<Su pName="number"><I2>1</I2></Su>
<Su pName="row"><I2>1</I2></Su>
<Su pName="column"><I2>1</I2></Su>
<Su pName="Odometer"><I2>Y</I2></Su>
<Su pName="AZMN_MIN"><F4>30.1</F4></Su>
<Su pName="AZMN_MAX"><F4>30.1</F4></Su>
<Su pName="APMN_MIN"><F4>30.1</F4></Su>
<Su pName="APMN_MAX"><F4>30.1</F4></Su>
<Su pName="ARMN_MIN"><F4>30.1</F4></Su>
<Su pName="ARMN_MAX"><F4>30.1</F4></Su>
<Su pName="AXMN_MIN"><F4>30.1</F4></Su>
<Su pName="AXMN_MAX"><F4>30.1</F4></Su>
<Su pName="AYMN_MIN"><F4>30.1</F4></Su>
<Su pName="AYMN_MAX"><F4>30.1</F4></Su>
<Su pName="AZMD_MIN"><F4>30.1</F4></Su>
<Su pName="AZMD_MAX"><F4>30.1</F4></Su>
<Su pName="APMD_MIN"><F4>30.1</F4></Su>
<Su pName="APMD_MAX"><F4>30.1</F4></Su>
<Su pName="ARMD_MIN"><F4>30.1</F4></Su>
<Su pName="ARMD_MAX"><F4>30.1</F4></Su>
<Su pName="AXMD_MIN"><F4>30.1</F4></Su>
<Su pName="AXMD_MAX"><F4>30.1</F4></Su>
<Su pName="AYMD_MIN"><F4>30.1</F4></Su>
<Su pName="AYMD_MAX"><F4>30.1</F4></Su>
<Su pName="SXMN_MIN"><F4>30.1</F4></Su>
<Su pName="SXMN_MAX"><F4>30.1</F4></Su>
<Su pName="SYMN_MIN"><F4>30.1</F4></Su>
<Su pName="SYMN_MAX"><F4>30.1</F4></Su>
<Su pName="STMN_MIN"><F4>30.1</F4></Su>
<Su pName="STMN_MAX"><F4>30.1</F4></Su>
<Su pName="SXMD_MIN"><F4>30.1</F4></Su>
<Su pName="SXMD_MAX"><F4>30.1</F4></Su>
<Su pName="SYMD_MIN"><F4>30.1</F4></Su>
<Su pName="SYMD_MAX"><F4>30.1</F4></Su>
<Su pName="STMD_MIN"><F4>30.1</F4></Su>
<Su pName="STMD_MAX"><F4>30.1</F4></Su>
</DV>
</Data>
</EngineeingData>

thanks,
BRAHM

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #5


thanks,
BRAHM

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: brazilnut52 | last post by:
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better I have created a simple COM DLL in .NET by using the COM class...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
2
by: Matthew Hood | last post by:
I'm at a loss on how to create global functions for my website. Essentially, I have several different functions I use throughout my site and I want to be able to put these in 1 file and call them...
4
by: Joe HM | last post by:
Hello - I have a Base Class where I want a New() implemented that can be called from the outside. This New() should create an instance of the appropriate cDerivedX Class ... The following...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
2
by: Joseph Geretz | last post by:
When I create a Form, the VB IDE creates the following files in the following hierarchy: Form1.cs Form1.Designer.cs Form1.resx Both Form1.cs and Form1.Designer.cs are partial implementations...
10
by: Robert Dailey | last post by:
Hi, I'm trying to create a Python equivalent of the C++ "ifstream" class, with slight behavior changes. Basically, I want to have a "filestream" object that will allow you to overload the...
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
4
by: Alan Mailer | last post by:
Again, I'm new to VB.net and there is something I need help with: Like (I assume) many of us, over time I want to be able to create some VB.net classes that I might want to use in more than one...
2
by: chandan | last post by:
Hi, How to create an instance of user control in a class(simple) file not in Page class file? As I tried I can do it in page class file but not in simple class file. Let me know the solution!! ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.