title: Conditional expressions in C# using XPath
body: <p>I've to create an entity object using the data available from an input xml. The value of one of the properties of this object depends on a condition and it looks like this in XPath :</p>
  
  <pre><code>if (//trade/tradeHeader/tradeTypology/tradeCategoryTypology[tradeCategory = 'TechnicalCancellation']) then 'Y' else 'N'")
  </code></pre>
  
  <p>And the below function takes this XPath and the xml document :</p>
  
  <pre><code>private static string GetValueFromXml(XmlDocument xDoc, string xPath)
      {
          var nod = xDoc.SelectSingleNode(xPath);
          if (nod != null)
              return nod.InnerText;
          return null;
      }
  </code></pre>
  
  <p>However, it doesn't work. The error is :</p>
  
  <p>'if (//trade/tradeHeader/tradeTypology/tradeCategoryTypology[tradeCategory = 'TechnicalCancellation']) then 'Y' else 'N'' has an invalid token.</p>
  
  <p>So my questions are :</p>
  
  <ol>
  <li>Is this conditional expression supported in C#/.Net (4.5) ?</li>
  <li>If not, what's the recommended approach when we have to check for multiple conditions in XPath ?</li>
  </ol>
  
  <p>Thanks
  Dileep</p>