Create Attribute with namespace in CSharp
Description
The following code shows how to create Attribute with namespace.
Example
/* w ww. java 2s .c o m*/
using System;
using System.Linq;
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 xmlTree = new XElement(aw + "Root",
new XAttribute(XNamespace.Xmlns + "aw", "http://www.domain.com"),
new XAttribute(aw + "Att", "attribute content")
);
XAttribute att = xmlTree.Attribute(aw + "Att");
Console.WriteLine(att);
}
}