static void Main(string[] args) { var xmlFile = @"C:\Projects\Chapter5\Chapter5.XmlLinq\Chapter5.XmlLinq.XmlCore\books.xml"; var books = new XmlBooks(xmlFile); var titles = books.GetBookTitles(); foreach (var title in titles) { Console.WriteLine(title); } Console.ReadLine(); }
public List <BookModel> GetBookCollection() { _books = (from book in XmlBooks.Element("root")?.Elements("row") select new BookModel( book.Element("Title")?.Value, book.Element("Author")?.Value, book.Element("Genre")?.Value, book.Element("SubGenre")?.Value, int.Parse((string)book.Element("Height")?.Value), book.Element("Publisher")?.Value )).ToList(); return(_books); }