Get Long Attr - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Get Long Attr

Demo Code


using System.Xml.Linq;
using System;/* w  w  w  .  j ava  2s  .  com*/

public class Main{
        public static long GetLongAttr(this XElement elem, string name)
        {
            long.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