Get Short Attr - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Get Short Attr

Demo Code


using System.Xml.Linq;
using System;//from  w ww.ja  va2  s . c  o  m

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