title: Creating XMLDocument throguh code in asp.net
body: <p>am trying to generate an XML document like this through code.</p>
  
  <pre><code>&lt;TestRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://localhost:2292/RMSchema.xsd"&gt;
      &lt;Version&gt;3&lt;/Version&gt;
      &lt;ApplicationHeader&gt;
          &lt;AppLanguage /&gt;
          &lt;UserId&gt;rmservice&lt;/UserId&gt;
      &lt;/ApplicationHeader&gt;
      &lt;CustomerData&gt;
          &lt;ExistingCustomerData&gt;
              &lt;MTN&gt;2084127182&lt;/MTN&gt;
          &lt;/ExistingCustomerData&gt;
      &lt;/CustomerData&gt;
  &lt;/TestRequest&gt;
  </code></pre>
  
  <p>I tried some samples. But they create xmlns for the children, which i dont need. Any help is really appreciated.</p>
  
  <p>I have tried the below code. But it is adding only xmlns to all children, which i dont need</p>
  
  <pre><code>XmlDocument xDocument = new XmlDocument();
  xDocument.AppendChild(xDocument.CreateXmlDeclaration("1.0", "windows-1252", null));
  XmlElement xRoot = xDocument.CreateElement("TestRequest", "XNamespace.Xmlns=http://www.w3.org/2001/XMLSchema-instance" + " xsi:noNamespaceSchemaLocation=" + "http://localhost:2292/RMSchema.xsd");
  xDocument.AppendChild(xRoot);
  xRoot.AppendChild(xDocument.CreateElement("Version")).InnerText = 1;
  </code></pre>
  
  <p>Thanks
  Tutu </p>
  
  <p>I have tried with </p>
  
  <pre><code>var xsi = "http://www.w3.org/2001/XMLSchema-instance";
              XmlElement xRoot = xDocument.CreateElement("xsi","RMRequest",xsi);
              xRoot.SetAttribute("noNamespaceSchemaLocation", xsi, "http://localhost:2292/RMSchema.xsd");
  
              xDocument.AppendChild(xRoot);
  Now the response is 
  
  &lt;?xml version=\"1.0\" encoding=\"windows-1252\"?&gt;&lt;xsi:TestRequest xsi:noNamespaceSchemaLocation=\"http://localhost:2292/RMSchema.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"&gt;
  </code></pre>