CSharp examples for System.Xml:XML Attribute
Get Enum Attr
using System.Xml.Linq; using System;// w ww. ja v a 2 s . co m public class Main{ public static TEnum GetEnumAttr<TEnum>(this XElement elem, string name) where TEnum : struct { Enum.TryParse<TEnum>(elem.GetAttrValue(name), out var v); return v; } public static string GetAttrValue(this XElement elem, string attrName) { return elem.Attribute(attrName)?.Value; } }