using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main()
{
string xmlFrag =" " +
"C#" +
"Programming" +
"";
NameTable nt = new NameTable();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
nsmgr.AddNamespace("bk", "urn:sample");
XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
XmlTextReader reader = new XmlTextReader(xmlFrag, XmlNodeType.Element, context);
while (reader.Read()){
if (reader.IsStartElement()){
if (reader.Prefix==String.Empty)
Console.WriteLine("<{0}>", reader.LocalName);
else{
Console.Write("<{0}:{1}>", reader.Prefix, reader.LocalName);
Console.WriteLine(" The namespace URI is " + reader.NamespaceURI);
}
}
}
reader.Close();
}
}