Attribute with namespace : Namespace « XML LINQ « C# / C Sharp






Attribute with namespace

 

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);
    }
}

   
  








Related examples in the same category

1.XElement with namespace
2.Create XElement with namespace
3.Query Attributes with namespace
4.Query attributes with namespace
5.XElement.GetDefaultNamespace gets the default XNamespace of this XElement.
6.XElement.GetNamespaceOfPrefix gets the namespace associated with a particular prefix for this XElement.
7.XElement.GetPrefixOfNamespace gets the prefix associated with a namespace for this XElement.
8.Two namespaces