将对象序列化为XML格式 [英] Serialize an object to XML format
问题描述
是否可以将对象序列化为XML格式(如以下格式)?
Is it possible to serialize an object to XML format like below format?
这是我现在正在使用的代码.
here is the code I am using now.
推荐答案
Serron,
Hi Serron,
谢谢您在这里发布.
对于您的问题,可以使用七个属性来指定输出格式.
For your question, there are seven properties could be used to specify the output format.
我制作了一个简单的代码示例来测试xml.这是我之前完成的xml序列化.
I make a simple code sample to test the xml. Here is the serialization of xml i done before.
Here is the only one property of specify output format. NewLineOnAttributes
settings.Indent = true;
settings.OmitXmlDeclaration = true;
settings.NewLineOnAttributes = true;
基于搜索,我找不到在多个节点中对齐属性的属性
Based on search, I do not find the property to align the attributes in several nodes
有关指定输出格式的属性,请参阅以下链接.
For the properties of specify output format, please refer to the following links.
https://msdn.microsoft.com/zh-cn/library/system.xml.xmlwritersettings(v = vs.110).aspx
最好的问候,
温迪
这篇关于将对象序列化为XML格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!