Create XAttribute with namespace : XAttribute « XML LINQ « C# / C Sharp






Create XAttribute with namespace

 

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(aw + "AnAttributeName", "Content"));
   }
}

   
  








Related examples in the same category

1.Using the LINQ to XML API to Create an XML Document
2.Creating an Attribute with Functional Construction
3.Creating an Attribute and Adding It to Its Element
4.XAttribute Class represents an XML attribute.
5.Create a new instance of the XAttribute class from the specified name and value.
6.Add XAttribute array to XElement
7.XAttribute.IsNamespaceDeclaration Property tells if this attribute is a namespace declaration.
8.XAttribute.Name Property returns the expanded name of this attribute.
9.XAttribute.NextAttribute Property returns the next attribute of the parent element.
10.XAttribute.NodeType Property returns the node type for this node.
11.XAttribute.PreviousAttribute Property returns the previous attribute of the parent element.
12.XAttribute.Remove removes this attribute from its parent element.
13.XAttribute.SetValue sets the value of this attribute.
14.XAttribute.ToString converts the current XAttribute object to a string representation.
15.XAttribute.Value gets or sets the value of this attribute.
16.It is easier to use casting when the attribute might or might not exist.
17.Cast the value of this XAttribute to a Boolean.
18.Cast the value of this XAttribute to a DateTime.