How can I make the xmlserializer only serialize plain xml?

前端 未结 4 446
遇见更好的自我
遇见更好的自我 2020-12-02 09:54

I need to get plain xml, without the at the beginning and xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-i

4条回答
  •  时光说笑
    2020-12-02 10:09

    Use the XmlSerializer.Serialize method overload where you can specify custom namespaces and pass there this.

    var emptyNs = new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty });
    serializer.Serialize(xmlWriter, objectToSerialze, emptyNs);
    

    passing null or empty array won't do the trick

提交回复
热议问题