Q:

How to choose an XML Node? (Using LINQ, XPath, anything is fine)

I have an XML like below :
<Decide Name="MemoryCheck" CommonUnit="MB">
    <Decision CellColor="Red" Status="Critical" Exp="&lt;=100" />
    <Decision CellColor="Yellow" Status="Warning" Exp="&lt;=200 &amp; &gt;100"/>
    <Decision CellColor="Green" Status="OK" Exp="&gt;200" />
</Decide>

For Input  50 MB, Output returned should be "Critical-Red"
For Input 142 MB, Output returned should be "Warning-Yellow"
For Input 212 MB, Output returned should be"OK-Green"   
How to go about this using C# ??
Xml Name is "Decide.xml" and Code I have now :
XmlDocument xmldecide = new XmlDocument();    
xmldecide.Load("C:\\Decide.xml");
XmlNodeList decidelist = xmldecide.GetElementsbyTagName("Decide");
XmlNode xdecide = decidelist[0];

string input = "50"; // Unit in MB
// Now I have to display the desired O/P "Critical-Red"
string input = "142"; // Unit in MB
// Now I have to display the desired O/P "Warning-Yellow"
string input = "212"; // Unit in MB
// Now I have to display the desired O/P "OK-Green"

A:

Just a suggestion - If you have control of that xml you should consider creating a min and max attribute. Having to parse out conditional and integer information from a single attribute is ugly. That said, assuming you can't change the xml, here's a solution. It assumes the conditionals in the attribute are always in a similar format.
    public static string AlertLevel(this XDocument decisionDocument, int size)
    {
        var queryResult = decisionDocument.Descendants("Decision");
        foreach (var item in queryResult)
        {
            var expAttribute = item.Attribute("Exp");
            if (expAttribute == null) continue;

            var returnString = CreateResultString(item);

            int minValue;
            int maxValue;
            if (expAttribute.Value.Contains(">") && expAttribute.Value.Contains("<="))
            {
                //evaluate minValue < size > maxValue
                var stringValue = expAttribute.Value.Replace("<=", string.Empty).Replace(">", string.Empty).Trim();
                var stringValueArray = stringValue.Split('&');

                if (int.TryParse(stringValueArray[1], out minValue) &&
                    int.TryParse(stringValueArray[0], out maxValue))
                {
                    if (minValue < size &&
                        size < maxValue)
                        return returnString;
                }
            }
            else if (expAttribute.Value.Contains(">"))
            {
                //evaluate size > value
                var stringValue = expAttribute.Value.Replace(">", string.Empty).Trim();
                if (int.TryParse(stringValue, out maxValue))
                {
                    if (size > maxValue)
                        return returnString;
                }
            }
            else if (expAttribute.Value.Contains("<="))
            {
                //else evaluate size < value
                var stringValue = expAttribute.Value.Replace("<=", string.Empty).Trim();
                if (int.TryParse(stringValue, out minValue))
                {
                    if (size < minValue)
                        return returnString;
                }
            }
        }

        return "No condition was met!";
    }

    private static string CreateResultString(XElement item)
    {
        var statusAttribute = item.Attribute("Status");
        var returnString = statusAttribute == null ? "Status" : statusAttribute.Value;

        var colorAttribute = item.Attribute("CellColor");
        returnString += colorAttribute == null ? "-Color" : "-" + colorAttribute.Value;
        return returnString;
    }

usage
var xmlDecide =  XDocument.Load("Decide.xml");
Console.WriteLine("50MB: " + xmlDecide.AlertLevel(50));
Console.WriteLine("142MB: " + xmlDecide.AlertLevel(142));
Console.WriteLine("212MB: " + xmlDecide.AlertLevel(212));

EDIT: You can use the same code for use with XmlDocument instead of XDocument. Just change "Attribute" to "Attributes.GetNamedItem" and "Descendants" to "GetElementsByTagName"

