Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We are storing config files as XML. With that being said, when reading the XML file, is it better to use LINQ to query the XML file or would using the XMLDocument and/or XMLNode classes better to use?

To me, it would seem that in this instance, LINQ is not necessary. But then I tried to think of any value of one over the other down the road if the structure of the XML were to change.

So my question is, is one method of reading XML better or more accepted way of doing it over the other?

share|improve this question
up vote 6 down vote accepted

LINQ, through XDocument is the recommended way to parse/read/query data in XML on the .NET platform.

There are many benefits including built in support for namespaces and implicit string conversions when building up a query.

share|improve this answer
Loading objects via LINQ to XML is a big benefit to me. – jfrankcarr Oct 18 '12 at 15:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.