CSharp examples for System.Xml:XML Attribute
Select Single XML Attribute Int
using System.Xml; using System;/*w ww. j a va 2 s . c o m*/ public class Main{ public static int? SelectSingleAttributeInt(XmlNode node, string name, int? defaultValue = null) { if (node?.Attributes == null) { return defaultValue; } workAttr = node.Attributes[name]; if (workAttr != null && int.TryParse(workAttr.Value, out iTryParse)) { return iTryParse; } return defaultValue; } }