CSharp examples for System.Xml:XML Element
Casting XML element to int64.
using System.Xml.Linq; using System;//from w w w .j a va 2 s. c om public class Main{ /// <summary> /// Casting element to int64. /// </summary> /// <param name="element"></param> /// <param name="key"></param> /// <returns></returns> public static Int64? CastElementToInt64(this XElement element, String key) { Int64 x; if (element.Element(key) == null) { return null; } var xElement = element.Element(key); if (xElement != null && Int64.TryParse(xElement.Value, out x)) { return x; } return null; } }