XML file using LINQ
Can any onle help how to write code to read and print an element from an XML file using LINQ with simple example?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Nov 14, 2011, 7:12 AM
http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/reading-xml-file-through-linq-a-few-tips/
AartiPosted Nov 14, 2011, 7:24 AM
Plz check this one:
may be it will help you
static XDocument GetStarbuzzData()
{
XDocument doc = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XComment("Starbuzz Customer Loyalty Data"),
new XElement("starbuzzData",
new XAttribute("storeName", "Park Slope"),
new XAttribute("location", "Brooklyn, NY"),
new XElement("person",
new XElement("personalInfo",
new XElement("name", "Janet Venutian"),
new XElement("zip", 11215)),
new XElement("favoriteDrink", "Choco Macchiato"),
new XElement("moneySpent", 255),
new XElement("visits", 50)),
new XElement("person",
new XElement("personalInfo",
new XElement("name", "Liz Nelson"),
new XElement("zip", 11238)),
new XElement("favoriteDrink", "Double Cappuccino"),
new XElement("moneySpent", 150),
new XElement("visits", 35)),
new XElement("person",
new XElement("personalInfo",
new XElement("name", "Matt Franks"),
new XElement("zip", 11217)),
new XElement("favoriteDrink", "Zesty Lemon Chai"),
new XElement("moneySpent", 75),
new XElement("visits", 15)),
new XElement("person",
new XElement("personalInfo",
new XElement("name", "Joe Ng"),
new XElement("zip", 11217)),
new XElement("favoriteDrink", "Banana Split in a Cup"),
new XElement("moneySpent", 60),
new XElement("visits", 10)),
new XElement("person",
new XElement("personalInfo",
new XElement("name", "Sarah Kalter"),
new XElement("zip", 11215)),
new XElement("favoriteDrink", "Boring Coffee"),
new XElement("moneySpent", 110),
new XElement("visits", 15))));
return doc;
}