I have to read the value from XML in C# based on some conditions. Below is my sample xml
<Properties>
<prop1 Name = " Apple" Defaultvalue="red">
<childprop Name = "special" Value="pink" >
</childprop>
</prop1>
<prop1 Name = " Orange" Defaultvalue="orange">
</prop1>
<prop1 Name = "Banana" Defaultvalue="yellow">
<childprop Name = "raw" Value="green" >
</childprop>
<childprop Name = "special" Value="red" >
</childprop>
</prop1>
</Properties>
For eg, if input is Orange, return value is defaultvalue = "Orange"
If the input is Banana, then return will be based on 2nd input. If it is Banana, raw, - return green if it is Banana, blank - return yellow if it is Banana, long - return yellow (No match for "long" so return default value at parent level).
What is the best way to achieve this.