Mega Code Archive

 
Categories / C# / XML LINQ
 

XElement GetDefaultNamespace gets the default XNamespace of this XElement

using System; using System.Linq; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; public class MainClass{    public static void Main(){         String xml = "<root xmlns='http://www.domain.com'/>";         XElement e = XElement.Parse(xml);         Console.WriteLine("Default namespace: {0}", e.GetDefaultNamespace());    } }