I need to get plain xml, without the <?xml version="1.0" encoding="utf-16"?>
at the beginning and xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
in first element from XmlSerializer
. How can I do it?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
Use the
XmlSerializer.Serialize
method overload where you can specify custom namespaces and pass there this.passing null or empty array won't do the trick
You can use XmlWriterSettings and set the property OmitXmlDeclaration to true as described in the msdn. Then use the XmlSerializer.Serialize(xmlWriter, objectToSerialize) as described here.
To put this all together - this works perfectly for me: