有谁知道为什么在数据合同序列化期间仍将命名空间添加到根目录?
XML:
<Response xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Event>
<Address>
.
.
.
</Response>
代码:
[DataContract(Name = "Response", Namespace = "")]
public class ApiEventResponse
{
[DataMember(EmitDefaultValue = false)]
public ApiEvent Event { get; set; }
}
var serializer = new DataContractSerializer(type, "Response", "");
return Task.Factory.StartNew(() =>
{
using (var xmlw = new XmlTextWriter(writeStream, Encoding))
{
xmlw.Formatting = Formatting.Indented;
serializer.WriteObject(xmlw, value);
}
});