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?
相关问题
- Sorting 3 numbers without branching [closed]
- Illegal to have multiple roots (start tag in epilo
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
Use
XmlWriterSettings.OmitXmlDeclaration
.Don't forget to set
XmlWriterSettings.ConformanceLevel
toConformanceLevel.Fragment
.You can subclass
XmlTextWriter
and override theWriteStartDocument()
method to do nothing:Usage:
Reference: This blog post from Scott Hanselman.
you can use
XmlWriter.Create()
with: