Hi all, I am trying query an xml file with dinamyc linq query. I have followed the scottGu's Blog
But I have a problem to make the where clause. This is the scenario.
<Rates>
<Rate id="1" tax="20.5" sex="M" name="Jhon">
<Rate id="2" tax="2.5" sex="F" name="Aline">
</Rate>
The idea is to query the xml using a filter with sex and name.
XDocument doc = XDocument.Load(new StringReader(xml));
var query = doc.Elements("Rates").Attributes().AsQueryable().Where("sex='M' and and name='Jhon'");
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.
But I have this error:
No property or field 'sex' exists in type 'XAttribute'
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.
Thx for any response! D.