Это мой XML-файл:
<lines>
<line>
<cell width="96" align="left" styleclass="5">Madame</cell>
<cell width="129" align="left" styleclass="5">NATHALIE</cell>
<cell width="187" align="left" styleclass="5">REGINENSI</cell>
<cell width="296" align="left" styleclass="5">production@holyfruits.com</cell>
<cell width="79" align="left" styleclass="5">CL00295</cell>
</line>
<line>
<cell width="96" align="left" styleclass="5">Madame</cell>
<cell width="129" align="left" styleclass="5">NICOLE</cell>
<cell width="187" align="left" styleclass="5">BAROIN</cell>
<cell width="296" align="left" styleclass="5">nbaroin@skendy-paris.com</cell>
<cell width="79" align="left" styleclass="5">CL00022</cell>
</line>
</lines>
Я пытаюсь получить все значения ячеек строки, где строка width="79" == CL00295
, но я изо всех сил пытаюсь найти правильный синтаксис для запроса linq. Вот что я сделал, что не работает:
var results = from sheet in doc.Descendants("line")
where sheet.Descendants("cell").ToString().ToLower() == listeClients[comboBoxClients.SelectedIndex].Id.ToLower()
select new
{
Value = sheet.Descendants("cell")
.Where(t => t.Attribute("width")
.Value == "96") // Civ
.First().Value,
Value2 = sheet.Descendants("cell")
.Where(t => t.Attribute("width")
.Value == "129") // Prenom
.First().Value,
Value3 = sheet.Descendants("cell")
.Where(t => t.Attribute("width")
.Value == "187") // Nom
.First().Value,
Value4 = sheet.Descendants("cell")
.Where(t => t.Attribute("width")
.Value == "296") // Email
.First().Value,
Value5 = sheet.Descendants("cell")
.Where(t => t.Attribute("width")
.Value == "79") // Code
.First().Value
}.ToString();
Полагаю, неправильная часть моего кода
where sheet.Descendants("cell").ToString().ToLower() == listeClients[comboBoxClients.SelectedIndex].Id.ToLower()
Но не мог понять, как заставить это работать ...
Спасибо за вашу помощь!