title: Filter XML with dynamic where clause
body: <p>I have the following XML:</p>
  
  <pre><code>&lt;Events&gt;
      &lt;Event&gt;
          &lt;EventID displayName="Event ID"&gt;1&lt;/EventID&gt;
          &lt;EventName displayName="Event Name"&gt;Some event&lt;/EventName&gt;
          &lt;OrgID displayName="Organization ID"&gt;8&lt;/OrgID&gt;
      &lt;/Event&gt;
      &lt;Event&gt;
          &lt;EventID displayName="Event ID"&gt;2&lt;/EventID&gt;
          &lt;EventName displayName="Event Name"&gt;Another Event&lt;/EventName&gt;
          &lt;OrgID displayName="Organization ID"&gt;10&lt;/OrgID&gt;
      &lt;/Event&gt;
  &lt;/Events&gt;
  </code></pre>
  
  <p>I want to be able to filter them by a where clause constructed dynamically. For example:</p>
  
  <pre><code>Where("Event ID = 2 AND (Organization ID = 8 OR Organization ID = 10)")
  </code></pre>
  
  <p>Please note that I can only use the displayName to filter the data. Obviously I can get the tag name from the displayName and construct the where clause, but that means some added calculations on the clients machine, which if possible, I'd like to avoid.</p>
  
  <p>I have explored the options to use <a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx" rel="nofollow">Dynamic Linq</a> or <a href="http://msdn.microsoft.com/en-us/library/det4aw50.aspx" rel="nofollow">DataTable.Select()</a> but with my limited knowledge on Linq, I cant seem to find an easy way to adopt those to filter XML data. Any help/hint is appreciated.</p>