Get XML Attribute Value from XElement - CSharp System.Xml

CSharp examples for System.Xml:XML Element

Description

Get XML Attribute Value from XElement

Demo Code


using System.Xml.Linq;
using System;/*from  w w w.j  a  v  a2s  . c  om*/

public class Main{
        public static string GetAttrValue(this XElement elem, string attrName)
        {
            return elem.Attribute(attrName)?.Value;
        }
}

Related Tutorials