title: Omitting all xsi and xsd namespaces when serializing an object in .NET?
body: <p>The code looks like this: </p>
  
  <pre><code>StringBuilder builder = new StringBuilder();
  XmlWriterSettings settings = new XmlWriterSettings();
  settings.OmitXmlDeclaration = true;
  using (XmlWriter xmlWriter = XmlWriter.Create(builder, settings))
  {
      XmlSerializer s = new XmlSerializer(objectToSerialize.GetType());
      s.Serialize(xmlWriter, objectToSerialize);
  }
  </code></pre>
  
  <p>The resulting serialized document includes namespaces, like so: </p>
  
  <pre><code>&lt;message xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" 
      xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" 
      xmlns="urn:something"&gt;
   ...
  &lt;/message&gt;
  </code></pre>
  
  <p>To remove the xsi and xsd namespaces, I can follow the answer from <a href="https://stackoverflow.com/questions/258960">How to serialize an object to XML without getting xmlns=”…”?</a>.</p>
  
  <p>I want my message tag as <code>&lt;message&gt;</code> (without any namespace attributes).  How can I do this?</p>