The overloads for the Write* methods allow you to associate an element or attribute with a namespace.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.Text;
using System.IO;
class Program
{
static void Main()
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
using (XmlWriter writer = XmlWriter.Create("foo.xml", settings))
{
writer.WriteStartElement("o", "customer", "http://yourDomain");
writer.WriteElementString("o", "firstname", "http://yourDomain", "Jack");
writer.WriteElementString("o", "lastname", "http://yourDomain", "Smith");
writer.WriteEndElement();
}
}
}
The output:
Jack
Smith