title: How do I add multiple namespaces to the root element with XmlDocument?
body: <p>I need to create an <code>XmlDocument</code> with a root element containing multiple namespaces.  Am using C# 2.0 or 3.0</p>
  
  <p>Here is my code:</p>
  
  <pre><code>XmlDocument doc = new XmlDocument();
  XmlElement root = doc.CreateElement("JOBS", "http://www.example.com");
  doc.AppendChild(root);
  
  XmlElement job = doc.CreateElement("JOB", "http://www.example.com");
  root.AppendChild(job);  
  
  XmlElement docInputs = doc.CreateElement("JOB", "DOCINPUTS", "http://www.example.com");
  job.AppendChild(docInputs);  
  
  XmlElement docInput = doc.CreateElement("JOB", "DOCINPUT", "http://www.example.com");
  docInputs.AppendChild(docInput);  
  
  XmlElement docOutput = doc.CreateElement("JOB", "DOCOUTPUT", "http://www.example.com");
  docOutputs.AppendChild(docOutput);  
  </code></pre>
  
  <p>The current output:</p>
  
  <pre><code>&lt;JOBS xmlns="http://www.example.com"&gt;
    &lt;JOB&gt;
      &lt;JOB:DOCINPUTS xmlns:JOB="http://www.example.com"&gt;
        &lt;JOB:DOCINPUT /&gt;
      &lt;/JOB:DOCINPUTS&gt;
      &lt;JOB:DOCOUTPUTS xmlns:JOB="http://www.example.com"&gt;
        &lt;JOB:DOCOUTPUT /&gt;
      &lt;/JOB:DOCOUTPUTS&gt;
    &lt;/JOB&gt;
  &lt;/JOBS&gt;
  </code></pre>
  
  <p>However, my desired output is:</p>
  
  <pre><code>&lt;JOBS xmlns:JOBS="http://www.example.com" xmlns:JOB="http://www.example.com"&gt;
    &lt;JOB&gt;
      &lt;JOB:DOCINPUTS&gt;
        &lt;JOB:DOCINPUT /&gt;
      &lt;/JOB:DOCINPUTS&gt;
    &lt;JOB:DOCOUTPUTS&gt;
      &lt;JOB:DOCOUTPUT /&gt;
    &lt;/JOB:DOCOUTPUTS&gt;
    &lt;/JOB&gt;
  &lt;/JOBS&gt;
  </code></pre>
  
  <p>My question: how do I create an <code>XmlDocument</code> that contains a root element with multiple namespaces?</p>