用XmlSerializer删除xsd和xsi前缀
The easiest way to do this is to use an overload of the Serialize method.
-- StringWriter sw=new StringWriter();
XmlTextWriter tw=new XmlTextWriter(sw);
XmlSerializerNamespcace xsn=new XmlSerializerNamespaces();
xsn.Add(String.Empty,String.Empty);
XmlSerializer serializer=new XmlSerializer(typeof(MyObject));
serializer.Serializer(tw,myObject,xsn);
According to Reflector,the main Serialize method checks if the XmlSerializerNamespace instance is null or has a zero length.If either are true,it uses a default XmlSerializerNampspaces instance which includes the xsd and xsi namespaces.
Happy programming~
-- StringWriter sw=new StringWriter();
XmlTextWriter tw=new XmlTextWriter(sw);
XmlSerializerNamespcace xsn=new XmlSerializerNamespaces();
xsn.Add(String.Empty,String.Empty);
XmlSerializer serializer=new XmlSerializer(typeof(MyObject));
serializer.Serializer(tw,myObject,xsn);
According to Reflector,the main Serialize method checks if the XmlSerializerNamespace instance is null or has a zero length.If either are true,it uses a default XmlSerializerNampspaces instance which includes the xsd and xsi namespaces.
Happy programming~