How do I convert a C# class to an XMLElement or XMLDocument

前端 未结 3 1028
春和景丽
春和景丽 2020-12-30 06:52

I have an C# class that I would like to serialize using XMLSerializer. But I would like to have it serialized to a XMLElement or XMLDocument. Is this possible or do I have t

3条回答
  •  长发绾君心
    2020-12-30 07:28

    You can create a new XmlDocument, then call CreateNavigator().AppendChild(). This will give you an XmlWriter you can pass to the Serialize method that will dump into the doc root.

提交回复
热议问题