Reputation: 13467
what is the best way to convert a class to a XML and vice versa?
I want to convert my class to xml for using XRule and I want to convert back it to class with early type of properties.
thanks
Upvotes: 4
Views: 8632
Reputation: 1322
XRule
sounds like it plays a similar role as an XML Schema (I'm not familiar with it). The XML Schema Definition (xsd.exe) tool allows you to generate common language runtime classes from XML files and vice-versa. More info can be found here.
Upvotes: 1
Reputation: 62459
Try the XmlSerializer
class: http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx
Upvotes: 1
Reputation: 37516
You can use XML Serialization to easily go from a class to XML, and the reverse. This tutorial does a good job explaining how to do it, and how to finely craft the resulting XML.
Upvotes: 5