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);
}
}
}
Related examples in the same category