Get Bool Elem - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Get Bool Elem

Demo Code


using System.Xml.Linq;
using System;/*w  w w  .  ja  va 2s  . co m*/

public class Main{
        public static bool GetBoolElem(this XElement elem, string name)
        {
            bool.TryParse(elem.GetElemValue(name), out var v);
            return v;
        }
        public static string GetElemValue(this XElement elem, string elemName)
        {
            return elem.Element(elemName)?.Value;
        }
}

Related Tutorials