LINQ to XML. ¿Cómo conseguir alguna cadena?
Tengo xml:
<?xml version="1.0" encoding="utf-8" ?>
<books>
<book>
<author>Ray</author>
<album>Other</album>
<cover size="large">LargeCover</cover>
<cover size="mini">MiniCover</cover>
</book>
</books>
¿Cómo obtener la cadena "MiniCover"?
Escribí el código, pero no funciona - la cadena está vacía;
string testLink = (@"Text.xml");
XDocument xml = XDocument.Load(testLink);
string cv = String.Empty;
var c = from cover in xml.Elements("book")
where (string)cover.Attribute("size").Value == "mini"
select cover.Value;
foreach (var item in c)
{
cv += item.ToString();
}
MessageBox.Show(cv);
¡Gracias!