(int)x.Element("prix")
x.prix
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.techheadbrothers.com/xlinq"
xmlns="http://www.techheadbrothers.com/xlinq"
elementFormDefault="qualified">
<xs:element name="commandes">
<xs:complexType>
<xs:sequence>
<xs:element ref="commande" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="commande">
<xs:element name="acheteur" type="xs:string"/>
<xs:element name="produit" type="xs:string"/>
<xs:element name="prix" type="xs:int"/>
<xs:attribute name="id" use="required" type="xs:string"/>
</xs:schema>
using www.techheadbrothers.com.xlinq;
static void DoJobNewWay3()
{
var data = new[] {
new { Id="123456", Acheteur="Pierre", Produit="Robot de cuisine", Prix=451 },
new { Id="7890123", Acheteur="Paul", Produit="Voiture de course", Prix=43657 },
new { Id="avcf568", Acheteur="Dupont", Produit="Casserole", Prix=356 }
};
XNamespace ns = "http://www.techheadbrothers.com/xlinq";
XElement xml = new XElement(ns + "commandes",
from d in data
select new XElement(ns + "commande",
new XAttribute("id", d.Id),
new XElement(ns + "acheteur", d.Acheteur),
new XElement(ns + "produit", d.Produit),
new XElement(ns + "prix", d.Prix)
)
);
commandes c = (commandes)xml;
var result = from x in c.commande
where x.prix < 500
select x.acheteur + " : " +
x.produit + " : " +
x.id;
foreach (string s in result)
Console.WriteLine(s);
}