Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I map XML to C# objects

I have an XML that I want to load to objects, manipulate those objects (set values, read values) and then save those XMLs back. It is important for me to have the XML in the structure (xsd) that I created.

One way to do that is to write my own serializer, but is there a built in support for it or open source in C# that I can use?

like image 486
Ragoler Avatar asked Sep 17 '08 21:09

Ragoler


People also ask

What is mapping in XML document?

XML Mapping is defined as an editor used to map one or more XML Document to a common XML file by this, we can generate a transformation document after defining Mapping. Mapping does delete, editing or any persistent work.

Which class is used in C for writing an XML file?

The XmlWrite class contains functionality to write data to XML documents. This class provides many write method to write XML document items.


1 Answers

You can generate serializable C# classes from a schema (xsd) using xsd.exe:

xsd.exe dependency1.xsd dependency2.xsd schema.xsd /out:outputDir 

If the schema has dependencies (included/imported schemas), they must all be included on the same command line.

like image 145
ckarras Avatar answered Sep 25 '22 13:09

ckarras