title: Omitting XML processing instruction when serializing an object
body: <p>I'm serializing an object in a C# VS2003 / .Net 1.1 application. I need it serialized without the processing instruction, however. The XmlSerializer class puts out something like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-16" ?&gt; 
  &lt;MyObject&gt;
      &lt;Property1&gt;Data&lt;/Property1&gt;
      &lt;Property2&gt;More Data&lt;/Property2&gt;
  &lt;/MyObject&gt;
  </code></pre>
  
  <p>Is there any way to get something like the following, without processing the resulting text to remove the tag?</p>
  
  <pre><code>&lt;MyObject&gt;
      &lt;Property1&gt;Data&lt;/Property1&gt;
      &lt;Property2&gt;More Data&lt;/Property2&gt;
  &lt;/MyObject&gt;
  </code></pre>
  
  <p>For those that are curious, my code looks like this...</p>
  
  <pre><code>XmlSerializer serializer = new XmlSerializer(typeof(MyObject));
  StringBuilder builder = new StringBuilder();
  
  using ( TextWriter stringWriter = new StringWriter(builder) )
  {
      serializer.Serialize(stringWriter, comments);
      return builder.ToString();
  }
  </code></pre>