Get Bool Attr - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Get Bool Attr

Demo Code


using System.Xml.Linq;
using System;//  w w w .  jav  a2s  .  c  o m

public class Main{
        public static bool GetBoolAttr(this XElement elem, string name)
        {
            bool.TryParse(elem.GetAttrValue(name), out var v);
            return v;
        }
        public static string GetAttrValue(this XElement elem, string attrName)
        {
            return elem.Attribute(attrName)?.Value;
        }
}

Related Tutorials