views:

46

answers:

1

I am serializing objects to XML with the following code:

    public static string SerializeToString<T>(T objectToBeSerialized, string defaultNamespace)
    {
        StringBuilder stringBuilder = new StringBuilder();
        XmlWriterSettings xmlSettings = new XmlWriterSettings()
        {
            CloseOutput = true,
            Indent = true,
            OmitXmlDeclaration = true
        };

        using (XmlWriter xmlWriter = XmlWriter.Create(stringBuilder, xmlSettings))
        {
            XmlSerializer serializer = new XmlSerializer(typeof(T), defaultNamespace);
            serializer.Serialize(xmlWriter, objectToBeSerialized);

            return stringBuilder.ToString();
        }
    }

I am already setting the default namespace ("http://schemas.somecompany.com/online/someservice/sync/2008/11"); however, my outputs still contain the default "xmlns:xsi" and "xmlns:xsd

<RootTag ***xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"*** xmlns="http://schemas.somecompany.com/online/someservice/sync/2008/11"&gt;
  <SomeTag>
    <More>false</More>
  </SomeTag>
</RootTage>

How can I get rid of them?