/ Published in: C#
See the URL.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?xml version="1.0" encoding="utf-8" ?> <Tutorials> <Tutorial> <Author>The Reddest</Author> <Title> Creating an XP Style WPF Button with Silverlight </Title> <Date>2/20/2008</Date> </Tutorial> <Tutorial> <Author>The Fattest</Author> <Title> Flex And Yahoo Maps </Title> <Date>2/12/2007</Date> </Tutorial> <Tutorial> <Author>The Tallest</Author> <Title> WPF Tutorial - Creating A Custom Panel Control </Title> <Date>2/18/2008</Date> </Tutorial> </Tutorials> XDocument xmlDoc = XDocument.Load("TestFile.xml"); var tutorials = from tutorial in xmlDoc.Descendants("Tutorial") select new { Author = tutorial.Element("Author").Value, Title = tutorial.Element("Title").Value, Date = tutorial.Element("Date").Value, };
URL: http://www.switchonthecode.com/tutorials/introduction-to-linq-simple-xml-parsing