title: C# creating XML output file without <?xml version="1.0" encoding="utf-8"?>
body: <p>I'm new to C# development so maybe a very simple question here.</p>
  
  <p>I'm trying to get an output which starts as this:</p>
  
  <pre><code>    &lt;ns0:NamespaceEnvelope xmlns:ns0="http://url.to.NamespaceEnvelope/v1.0"&gt;
  </code></pre>
  
  <p>But am getting this: </p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;ns0&gt;
  </code></pre>
  
  <p>This is my source:</p>
  
  <pre><code>        XmlWriterSettings settings = new XmlWriterSettings();
          settings.Indent = true;
          settings.IndentChars = "  ";
          settings.NewLineChars = "\r\n";
          settings.NewLineHandling = NewLineHandling.Replace;
  
          using (XmlWriter writer = XmlWriter.Create("employees.xml", settings))
          {
              writer.WriteStartDocument();
              writer.WriteStartElement("ns0"); 
              writer.WriteStartElement("Firstsection");
  </code></pre>
  
  <p>How can I get rid of:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p>And how can I change:</p>
  
  <pre><code>     writer.WriteStartElement("ns0"); 
  </code></pre>
  
  <p>To be able to output it as:</p>
  
  <pre><code>    &lt;ns0:NamespaceEnvelope xmlns:ns0="http://url.to.NamespaceEnvelope/v1.0"&gt;
  </code></pre>
  
  <p>As this:</p>
  
  <pre><code>    writer.WriteStartElement("ns0:NamespaceEnvelope xmlns:ns0="http://url.to.NamespaceEnvelope/v1.0"");
  </code></pre>
  
  <p>Is asking for an ")" probably because of the "surrounding the http part.</p>
  
  <p>Any help is highly appreciated.</p>