CSharp examples for System.Xml:XML Attribute
Get Int Attribute from XML
using System.Xml; using System.Text; using System.Linq; using System.Collections.Generic; using System;/* www . ja v a2s. co m*/ public class Main{ public static int GetIntAttr(this XmlElement element, string attrName) { try { return int.Parse(element.GetAttr(attrName)); } catch (Exception) { return 0; } } public static string GetAttr(this XmlElement element, string attrName) { XmlAttribute attr = element.Attributes[attrName]; return (attr != null) ? attr.Value : string.Empty; } }