How do I map XML to C# objects

前端 未结 9 1851
旧巷少年郎
旧巷少年郎 2020-11-27 13:37

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

9条回答
  •  有刺的猬
    2020-11-27 14:00

    using System.Xml.Serialization; this namespace has all the attributes you'll need if you want to map your xml to any random object. Alternatively you can use the xsd.exe tool

    xsd file.xsd {/classes | /dataset} [/element:element] [/language:language] [/namespace:namespace] [/outputdir:directory] [URI:uri] which will take your xsd files and create c# or vb.net classes out of them.

    http://msdn.microsoft.com/en-us/library/x6c1kb0s(VS.71).aspx

提交回复
热议问题