XElement.Attributes returns a collection of attributes of this element.
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("Att1", "content1"),
new XAttribute("Att2", "content2")
);
IEnumerable<XAttribute> attList = from at in xmlTree.Attributes() select at;
foreach (XAttribute att in attList)
Console.WriteLine(att);
}
}
Related examples in the same category