Get Short Elem - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Get Short Elem

Demo Code


using System.Xml.Linq;
using System;//  w w w .j  a  v  a  2  s . co m

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