Click here to Skip to main content
Click here to Skip to main content
Alternatives (2)

Tagged as

Go to top

Reading XML documents using LINQ

, 15 Jan 2011
Reading XML documents using LINQ

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

14 Jan 2011
Andrew Rissing
Not really that big of a change, but I'd go with an XPath solution. It locates all of the "magic strings" into one spot.var nodes = from element in XElement.Load("Books.xml").XPathSelectElements("/Books/Book/Subject") select new { Value =...
18 Jan 2011
Richard Deeming
Another option would be to use the Elements extension method[^]:var root = XElement.Load("Books.xml"); var books = from node in root.Elements("Book").Elements("Subject") select node.Value.Trim(); foreach (string subject in books){ listBox1.Items.Add(subject);}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Anupama Roy
Software Developer (Senior) Dell
India India
I am a .Net developer working on C#,Asp.net,WCF,WF etc.I would like to utilize this space to share whatever I have come across so far working in .Net so that you can also learn & explore.
 
I hope you find these posts useful.I’d love to hear from you,so please post in your comments/feedback.
 
Visit my blog http://dotnetforyou.wordpress.com/ for more technical articles:

| | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 16 Jan 2011
Article Copyright 2011 by Anupama Roy
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid