如何从xml字典序列化中正确删除xmln:xsi和xmlns:xsd

时间:2010-07-16 10:17:38

标签: c# xml vb.net dictionary xml-serialization

1 个答案:

答案 0 :(得分:2)

这是我用来序列化到我的对象的代码o

XmlSerializerNamespaces XSN = new XmlSerializerNamespaces();
XSN.Add("", "");
XmlWriterSettings XWS = new XmlWriterSettings();
XWS.OmitXmlDeclaration = true;
StringBuilder XmlStr = new StringBuilder();
XmlSerializer x = new XmlSerializer(o.GetType());
x.Serialize(XmlTextWriter.Create(XmlStr, XWS), o, XSN);