using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

public static class XmlNodeExtensions
{
	public static string GetAttributeValue(this XmlNode node, string name, string defaultValue)
	{
	    XmlAttribute attribute = node.Attributes[name];
	    if (attribute != null)
	    {
	        return attribute.Value;
	    }
	
	    return defaultValue;
	}
	
	public static int GetAttributeValueInt(this XmlNode node, string name, int defaultValue)
	{
	    int value = defaultValue;
	    XmlAttribute attribute = node.Attributes[name];
	    if (attribute != null)
	    {
	        int.TryParse(attribute.Value, out value);
	    }
	
	    return value;
	}
	
	public static bool GetAttributeValueBool(this XmlNode node, string name, bool defaultValue)
	{
	    bool value = defaultValue;
	    XmlAttribute attribute = node.Attributes[name];
	    if (attribute != null)
	    {
	        bool.TryParse(attribute.Value, out value);
	    }
	
	    return value;
	}
}
