Get XAttribute by name in CSharp

Description

The following code shows how to get XAttribute by name.

Example


  //ww  w .j  av a 2s  .  co  m
   
using System;
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;


public class MainClass{
   public static void Main(){
        XElement xmlTree = new XElement("Root",
            new XAttribute("Att", "attribute content")
        );
        XAttribute att = xmlTree.Attribute("Att");
        Console.WriteLine(att);

   }
}




















Home »
  C# Tutorial »
    XML »




Load Parse
Document
Element
Attribute
Namespace
Query
Save
Schema
Style