CSharp examples for System.Xml:XML Attribute
get Bool XML Attribute
using System.Xml; using System.Collections.Generic; using System.Collections; using System;//w w w .ja v a2 s . co m public class Main{ public static bool getBoolAttr( XmlElement el, string attrName, bool defaultValue = false ){ if (el.HasAttribute (attrName) == false) { return defaultValue; } string attrVal = el.GetAttribute (attrName); if (attrVal == "1" || attrVal == "true" || attrVal == "True" || attrVal == "TRUE" || attrVal == "yes" || attrVal == "Yes" || attrVal == "YES" || attrVal == "on" || attrVal == "On" || attrVal == "ON" ) { return true; } else { return false; } } }