views:

38

answers:

4

Hi,

I have a couple of XML files that are used to control unattended installations of sharepoint. I need to create a simple desktop application that will create / modify these xml files.

Before i go through and create a load of stuff manually is there any way i can automate some of the process. I.E. can i generate my objects from an XML file?

Could i even create the starting of a GUI from the XML file or object?

I am using c# and can use visual studio 2008 or 2010 and up to .NET 4

+3  A: 

You can create a XSD file based on the xml files and with the xsd compiler you can create classes based on the XSD files.

create a XSD from XML use like this

xsd myFile.xml /outputdir:myOutputDir

and create classes from XSD like this

xsd schema.xsd /classes

and loading in code like this

StreamReader str = new StreamReader("schema.xml");
XmlSerializer xSerializer = new XmlSerializer(typeof(myGeneratedClass));

myGeneratedClass myCdCatalogue = (myGeneratedClass)xSerializer.Deserialize(str);

regards

ReaperXmac
Thanks, this worked great.
Buzzby
A: 

I've just found this post which describes how to...

read in XML from a file using HTTPService, put the data in an XMLListCollection, and then iterate through the data, creating UI elements.

It might provide you with a starting point for your application.

ChrisF
A: 

Hi Buzzby

Another option would be to use InfoPath, creating xml-files are the whole purpose of that Office product

Per Jakobsen
Would have loved to use infopath but it needs to be a lightweight app.
Buzzby
A: 

Take a look at OXM. It fits your purpose exactly.

Delucia