title: C# XML Dynamic LINQ
body: <p>I am trying query an xml file with dinamyc linq query. I have followed the scottGu's Blog </p>
  
  <p><a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx" rel="nofollow">scottGu's Blog</a></p>
  
  <p>But I have a problem to make the where clause. This is the scenario.</p>
  
  <p><code>&lt;Rates&gt;</code><br/>
     <code>&lt;Rate id="1" tax="20.5" sex="M" name="Jhon"&gt;</code><br/>
     <code>&lt;Rate id="2" tax="2.5" sex="F" name="Aline"&gt;</code><br/>
  <code>&lt;/Rate&gt;</code></p>
  
  <p>The idea is to query the xml using a filter with sex and name.</p>
  
  <p><code>XDocument doc = XDocument.Load(new StringReader(xml));</code><br/>
  <code>var query = doc.Elements("Rates").Attributes().AsQueryable().Where("sex='M' and and name='Jhon'");</code></p>
  
  <p>I use this method because with SelectSingleNode() method I have problem if the parameter in where clause are not ordered and because the query is dynamic.</p>
  
  <p>But I have this error:<br/>
  <code>No property or field 'sex' exists in type 'XAttribute'</code></p>
  
  <p>I don't know is syntax are correct, and if is the right way to make a dynamic query. I have not found example in internet with xml query.</p>
  
  <p>Thx for any response!
  D.</p>