I have the following xml:
<bookstore>
<book IMDB="11-023-2022">
<title>Hamlet 2</title>
<comments>
<user rating="2">good enough</user>
<user rating="1">didnt read it</user>
<user rating="5">didnt read it but title is good</user>
</comments>
</book>
</bookstore>
I have an AverageUserRating property which i supposed to fill while parsing in the following format, I also have no idea how to cast comments into list. I tried everything, I can't use nuget packages like xpath. Thank you for your help.
return xdoc.Descendants("book").Select(n => new Books()
{
IMDB = n.Attribute("IMDB").Value,
Title = n.Element("title").Value,
//Comments = (List<string>)(n.Elements("user")), ???
//AverageUserRating= ???
}).ToList();