XML serialize - remove first default tag <p>I have the following class:</p> <pre><code>public class RecordDTO { public int TabIndex { get; set; } public int TaxYear { get; set; } } </code></pre> <p>I serialize an instance of the class: </p> <pre><code> System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(record.GetType()); string xmlstring = null; using (StringWriter writer = new StringWriter()) { x.Serialize(writer, record); xmlstring = writer.ToString(); } </code></pre> <p>The result is:</p> <pre><code> "&lt;?xml version="1.0" encoding="utf-16"?&gt; &lt;RecordDTO xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;TabIndex&gt;1&lt;/TabIndex&gt; &lt;TaxYear&gt;2014&lt;/TaxYear&gt; &lt;/RecordDTO&gt;" </code></pre> <p><strong>I want the first row</strong> <code>(&lt;?xml version="1.0" encoding="utf-16"?&gt;)</code> <strong>to not be created at the xmlstring.</strong> <strong>What should I do?</strong></p> <p><strong>About the 'duplicate' claim of rene, Unihedron, Infinite Recursion, har07, Athari: The other question use xmlWriter, and I need stringWriter. If you have way to do it by stringWriter; or you have a way to use xmlWriter and accept string - you can tell about.</strong></p>