XAttribute namespace
In this chapter you will learn:
Create XAttribute with namespace
using System;/*j a v a 2 s . c o m*/
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(aw + "AnAttributeName", "Content"));
}
}
XAttribute.IsNamespaceDeclaration
using System;//from ja v a2 s.com
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);
}
}
}
Next chapter...
What you will learn in the next chapter:
Home » C# Tutorial » XML Linq