title: The prefix " cannot be redefined from " to <url> within the same start element tag
body: <p>I'm trying to generate the following xml element using C#.</p>
  
  <pre><code>&lt;Foo xmlns="http://schemas.foo.com" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xsi:schemaLocation="http://schemas.foo.com
   http://schemas.foo.com/Current/xsd/Foo.xsd"&gt;
  </code></pre>
  
  <p>The problem that I'm having is that I get the exception: </p>
  
  <blockquote>
    <p>The prefix " cannot be redefined from " to  within the same start
    element tag.</p>
  </blockquote>
  
  <p>This is my c# code:</p>
  
  <pre><code>XNamespace xsi = "http://www.w3.org/2001/XMLSchema-instance";
  XElement foo = new XElement("Foo", new XAttribute("xmlns", "http://schemas.foo.com"),
                                     new XAttribute(XNamespace.Xmlns + "xsi", "http://www.w3.org/2001/XMLSchema-instance"),
                                     new XAttribute(xsi + "schemaLocation", "http://schemas.foo.com http://schemas.foo.com/Current/xsd/Foo.xsd"));
  </code></pre>
  
  <p>How can I fix this? I'm trying to send the generated xml as the body of a SOAP message and I need it to be in this format for the receiver.</p>
  
  <p><strong>EDIT:</strong> I found my answer on another question. <a href="https://stackoverflow.com/questions/724976/controlling-the-order-of-xml-namepaces?rq=1">Controlling the order of XML namepaces</a></p>