Click here to Skip to main content
14,022,571 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


23 bookmarked
Posted 14 Jan 2011
Licenced CPOL

Reading XML documents using LINQ

, 15 Jan 2011
Rate this:
Please Sign up or sign in to vote.
Reading XML documents using LINQ
LINQ simplifies working with XML data & you need not use Xpath or XQuery for reading XML. This tip is about querying XML using LINQ.
<?xml version="1.0" encoding="utf-8" ?>
      Social Science

     General Science

This queries the XML & populates the listbox with values of Subject.

var books = from nodes in System.Xml.Linq.XElement.Load("Books.xml").Elements("Book") select nodes;

            if (books != null)
                foreach (var b in books)



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


About the Author

Anupama Roy
Software Developer (Senior) Dell
India India
I am a .Net developer working on C#,,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 for more technical articles:

You may also be interested in...


Comments and Discussions

QuestionMinh Pin
hoangminh1235-Aug-13 22:31
memberhoangminh1235-Aug-13 22:31 
GeneralMy vote of 4 Pin
chait30115-Jun-13 13:00
memberchait30115-Jun-13 13:00 
GeneralReason for my vote of 5 just the biscuit thanks for the tip! Pin
Erik Rude22-Feb-12 22:51
memberErik Rude22-Feb-12 22:51 
GeneralReason for my vote of 5 Just what I needed. Pin
[Schnell]Konig18-Dec-11 12:26
member[Schnell]Konig18-Dec-11 12:26 
GeneralIn most cases, a query expression of "from x in source selec... Pin
Richard Deeming18-Jan-11 9:19
mveRichard Deeming18-Jan-11 9:19 
Question?......really? Pin
trooper081417-Jan-11 3:34
membertrooper081417-Jan-11 3:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190417.4 | Last Updated 16 Jan 2011
Article Copyright 2011 by Anupama Roy
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid