CSharp examples for System.Xml:XML Attribute
Safe Parse Xml Attribute Bool
using System.Xml; using System.Text; using System.Collections.Generic; using System;//w w w .j a va 2 s . co m public class Main{ public static bool SafeParseXmlAttribute_Bool(XmlNode xNode, string attributeName, bool defaultValue) { var attr = xNode.Attributes[attributeName]; if ((attr == null) || (string.IsNullOrWhiteSpace(attr.Value))) { return defaultValue; } return System.Convert.ToBoolean(attr.Value); } }