Display the second namespace on screen
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Xml; using System.Xml.Linq; using System.IO; public class MainClass{ public static void Main(string[] args){ XDocument NewDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), new XElement("Root", "MyDoc")); XElement ThisElement = new XElement("{http://www.java2s.com/}First",new XAttribute(XNamespace.Xmlns + "NewNS", "http://www.microsoft.com"),"Hello"); Console.WriteLine(ThisElement.ToString()); XName ThisName = ThisElement.Name; Console.WriteLine(ThisName.LocalName + "\r\nNamespace: " + ThisName.Namespace + "\r\nNamespace Name: " + ThisName.NamespaceName); ThisName = ThisElement.Attribute(XNamespace.Xmlns + "NewNS").Name; Console.WriteLine("Second Local Name: " + ThisName.LocalName + "\r\nSecond Namespace: " + ThisName.Namespace + "\r\nSecond Namespace Name: " + ThisName.NamespaceName + "\r\nAttribute Value: " + ThisElement.Attribute(XNamespace.Xmlns + "NewNS").Value); } }