title: XmlDocument - The prefix '' cannot be redefined from '' to 'X'
body: <p>I am doing this:</p>
  
  <pre><code> var xml = new XmlDocument();
   xml.AppendChild(xml.CreateXmlDeclaration("1.0", Encoding.UTF8.BodyName, "yes"));
   var el = (XmlElement)xml.AppendChild(xml.CreateElement("Document"));           
   el.SetAttribute("xmlns", "urn:iso:std:iso:20022:tech:xsd:" + SepaSchemaUtils.SepaSchemaToString(schema));
  </code></pre>
  
  <p>Then to get the XML indented I do:</p>
  
  <pre><code>StringBuilder sb = new StringBuilder();
  XmlWriterSettings settings = new XmlWriterSettings
  {
      Indent = true,
      IndentChars = "  ",
      NewLineChars = "\r\n",
      NewLineHandling = NewLineHandling.Replace
  };
  using (XmlWriter writer = XmlWriter.Create(sb, settings))
  {
      doc.Save(writer);
  }
  </code></pre>
  
  <p>I am getting an exception when doc.Save(writer) is executed.</p>
  
  <blockquote>
    <p>System.Xml.XmlException: The prefix '' cannot be redefined from '' to
    'urn:iso:std:iso:20022:tech:xsd:pain.001.001.03' within the same start
    element tag.</p>
  </blockquote>
  
  <p>I've already tried everything I could find. Thank you.</p>