Converting array of objects to XML in C#

前端 未结 2 1011
忘了有多久
忘了有多久 2021-01-17 20:50

I know there\'s no built in converter to convert an array of objects to XML. Is there a quick rudimentary way to create a XML out of the array to help me do a LINQ to XML jo

2条回答
  •  無奈伤痛
    2021-01-17 21:16

    You can always use XmlSerializer to transform a list of C# objects to XML document. The result of the serialization may be customized by using metadata attributes to designate, for example, root nodes or which class property is to be ignored etc... You will definitely need to apply the attributes to make the resulting XML conform as much as possible to your requirements.

    Here is a basic tutorial on serializing an Object to XML:

提交回复
热议问题