Writes out the namespace-qualified name.
using System;
using System.IO;
using System.Xml;
public class Sample
{
private const string filename = "sampledata.xml";
public static void Main()
{
XmlTextWriter writer = null;
writer = new XmlTextWriter (filename, null);
writer.Formatting = Formatting.Indented;
writer.WriteStartElement("schema");
writer.WriteAttributeString("xmlns", null,"http://www.w3.org/2001/XMLSchema");
writer.WriteAttributeString("xmlns","po",null,"http://domain.com/po");
writer.WriteStartElement("element");
writer.WriteAttributeString("name", "purchaseOrder");
writer.WriteStartAttribute(null,"type", null);
writer.WriteQualifiedName("PurchaseOrder", "http://domain.com/po");
writer.WriteEndAttribute();
writer.WriteEndElement();
writer.WriteEndElement();
writer.Flush();
writer.Close();
XmlDocument doc = new XmlDocument();
doc.PreserveWhitespace = true;
doc.Load(filename);
Console.Write(doc.InnerXml);
}
}
Related examples in the same category