C#: Help Needed To Write Recursive Method that analyse data from XML
===

I need C# logic that analyse some conditions from an XML file. The logic should be able evaluate the conditions and just tell me whether the final result is true or false:

Example : 1 :
a rule (A AND B AND C) is represented like this in the XML file:

       <Evaluate>       
            <!-- (A AND B AND C)-->
            <AND>                               
                <Condition Name="A" Operator="!=" Value="0"/>
                <Condition Name="B" Operator="!=" Value="0"/>
                <Condition Name="C" Operator="==" Value="17"/>
            </AND>                
       </Evaluate>

I know this is simple thing to do, But below are some complex rules that needs evaluation from C# code:
Example : 2:

    <Evaluate>
        <!-- (A AND B) OR C -->
        <OR>
            <Condition Name="C" Operator="==" Value="17"/>
            <AND>
                <Condition Name="A" Operator="!=" Value="0"/>
                <Condition Name="B" Operator="!=" Value="0"/>
            </AND>            
        </OR>                
    </Evaluate>

Example: 3 :

    <Evaluate>
        <!-- (A)  OR ((B AND C) OR D)-->
        <OR>
            <Condition Name="A" Operator="!=" Value="0"/>
            <OR>
                <Condition Name="D" Operator="!=" Value="0"/>
                <AND>
                    <Condition Name="B" Operator="!=" Value="0"/>
                    <Condition Name="C" Operator="!=" Value="0"/>                    
                </AND>
            </OR>
        </OR>               
    </Evaluate>

Example: 4 :

    <Evaluate>
        <!-- (A AND B)  OR ((C AND D) OR E)-->
        <OR>
            <AND>
                <Condition Name="A" Operator="!=" Value="0"/>
                <Condition Name="B" Operator="!=" Value="0"/>
            </AND>            
            <OR>
                <Condition Name="E" Operator="!=" Value="0"/>
                <AND>
                    <Condition Name="C" Operator="!=" Value="0"/>
                    <Condition Name="D" Operator="!=" Value="0"/>                    
                </AND>
            </OR>
        </OR>
    </Evaluate>

To explain you about the the <Condition> Xml node:

    <Condition Name="D" Operator="!=" Value="0"/>     

               
means that the (D != 0) or not.

Your help would be appreciated.





