Remove q1 and all namespaces from xml

前端 未结 3 975
渐次进展
渐次进展 2021-01-18 22:14

I\'m given a xsd generated C# POCO object that I need to convert to xml. The expected payload however doesn\'t match the xsds I was given. Specifically, I need to omit the

3条回答
  •  余生分开走
    2021-01-18 22:35

    This is another solution:

    XmlWriterSettings settings = new XmlWriterSettings();
    //If you wish Encoding
    settings.Encoding = Encoding.GetEncoding("ISO-8859-1");
    
    using (XmlWriter xmlWriter = XmlWriter.Create(tempFilePath, settings))
    {
         var ns = new XmlSerializerNamespaces();
         ns.Add("", "http://thecompany.com");
         XmlSerializer s = new XmlSerializer(YOUROBJECT.GetType(), "http://thecompany.com");    
         s.Serialize(xmlWriter, YOUROBJECT, ns);
    
    }
    

提交回复
热议问题