Mega Code Archive

 
Categories / C# / XML LINQ
 

XAttribute IsNamespaceDeclaration Property tells if this attribute is a namespace declaration

using System; using System.Linq; using System.Xml; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; public class MainClass{    public static void Main(){         XNamespace aw = "http://www.domain.com";         XElement root = new XElement(aw + "Root",             new XAttribute(XNamespace.Xmlns + "aw", "http://www.domain.com"),             new XAttribute(aw + "Att", "content")         );                  foreach (XAttribute att in root.Attributes()) {             if (att.IsNamespaceDeclaration)                 Console.WriteLine("{0} is a namespace declaration", att.Name);             else                 Console.WriteLine("{0} is not a namespace declaration", att.Name);         }    } }