Ho il seguente file xmlleggere il file XML utilizzando LINQ
<?xml version="1.0" encoding="utf-8"?>
<Users>
<User>
<Name>John Smith</Name>
<test>
<Date>23.05.2011</Date>
<points>33</points>
</test>
<test>
<Date>22.06.2011</Date>
<points>29</points>
</test>
</User>
</Users>
e vorrei utilizzare LINQ per estrarre le date e le punte delle prove in cui nome utente è "John Smith" ..
come potrei costruire il mio linq?
ho fatto quanto segue, ma non funziona come vorrei:
XElement main = XElement.Load(@"users.xml");
string t = "John Smith";
var v = from user in main.Elements("User")
where t == users.Element("Name").Value
select users;
MessageBox.Show(v.First().Element("Date").Value.ToString());
Il tuo codice non dovrebbe essere compilato. Stai usando 'utenti' dove dovresti usare' utente'. E hai errori di battitura nella tua inizializzazione 't'. – svick