Creating a specific XML document using namespaces in C#

You should try it that way

  XmlDocument doc = new XmlDocument();  

  XmlSchema schema = new XmlSchema();
  schema.Namespaces.Add("xmlns", "http://www.sample.com/file");

  doc.Schemas.Add(schema);

Do not forget to include the following namespaces:

using System.Xml.Schema;
using System.Xml;

I personally prefer to use the common XmlElement and its attributes for declaring namespaces. I know there are better ways, but this one never fails.

Try something like this:

xRootElement.SetAttribute("xmlns:xsi", "http://example.com/xmlns1");