Click here to Skip to main content
Licence 
First Posted 3 Jul 2006
Views 30,487
Bookmarked 19 times

Xml to VB.net Class Generator

By | 3 Jul 2006 | Article
Converts XML Document to VB.Net Class

Introduction

Sample screenshot

XML2Class Generator converts the XML Document to VB.Net Class. The reason behind developing this application was I have some components those returns xml string. I want to expose them out as strongly typed classes. I tried to implement Dataset by creating schema from xml and generating Dataset, but for the two reasons I left that idea.

Reason 1. Some of the tags in the xml documents have attributes and the dataset was created with child tables for each tag that has the attributes. I don’t like that approach.

Reason 2. I felt Dataset is too heavy to do this kind of work and it has lot of functionality that is not useful in this scenario.


Then I tought i would write a class manually which reads the xml document and copy the values to the class properties. But I felt it is laborious job, since the xml document has so many tags. I left this idea too.


Hence I decided to write XML to Class generator.

 

Features:

1. Generates class from xml. (This version only supports XML file with one root node )

2. Handles the xml attributes by converting them as separate properties. The xml attribute will be rendered as a property with this format “NodeName_Attributename”.

Example : <Name First=”Srinivas”/>

Attribute First will be created as property Name_First.

3.Can Be serialized from the xml.

I have included a sample project which has the logic to create an instance of the above generated class by deserializing from the xml.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Srinivas-Miriyala

Software Developer (Senior)

United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 5 Pinmembersomethingfree1235:28 18 Jan '11  
GeneralMy vote of 1 PinmvpDave Kreskowiak15:44 7 Mar '10  
GeneralCouple things... [modified] PinmemberBoneSoft9:40 3 Jul '06  
GeneralRe: Couple things... Pinmemberzhaojicheng2:00 18 Feb '09  
GeneralRe: Couple things... PinmemberBoneSoft2:20 18 Feb '09  
GeneralRe: Couple things... Pinmemberzhaojicheng4:21 18 Feb '09  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 3 Jul 2006
Article Copyright 2006 by Srinivas-Miriyala
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid