if use Descendants
XDocument xDoc = XDocument.Load(@"C:\Users\anishmarokey\Desktop\XMLFile1.xml");
var result = from book in xDoc.Descendants("Book")
select new
{
Title = book.Attribute("Title"),
Author = book.Attribute("Author")
};
if use Elements
XDocument xDoc = XDocument.Load(@"C:\Users\anishmarokey\Desktop\XMLFile1.xml");
var result = from book in xDoc.Elements("Titles").Elements("Book")
select new
{
Title = book.Attribute("Title"),
Author = book.Attribute("Author")
};
No comments:
Post a Comment