如何使用XML编写不声明元素创建XML [英] how to create an xml using xml writer without declaration element

查看:140
本文介绍了如何使用XML编写不声明元素创建XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 XmlWriter.Create()来获得一个作家实例,然后写XML,但结果有< XML版本=1.0编码=UTF-16> ,我怎么告诉我的XML编写器不产生呢?

I am using XmlWriter.Create() to get a writer instance then write the XML, but the result has the <?xml version="1.0" encoding="utf-16" ?>, how do I tell my xml writer do not produce it?

推荐答案

使用<一个href="http://msdn.microsoft.com/en-us/library/system.xml.xmlwritersettings.omitxmldeclaration.aspx"><$c$c>XmlWriterSettings.OmitXmlDeclaration.

不要忘记设置 XmlWriterSettings.ConformanceLevel ConformanceLevel.Fragment

这篇关于如何使用XML编写不声明元素创建XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆