Reading and querying XML data is good with Link to XML in C#. LINQ to XML provides an in-memory XML programming interface that leverages the .NET Language-Integrated Query (LINQ) Framework.

Documentation and examples of how to use it are published at  LINQ to XML (C#), but in this post I post down useful for me snippets.

First variable is a filepath.

 

1. Read and query Read via XDocument

In case of XDocument you load all the nodes of XML-file. To get the top-level node you should use Root. You can add where clause according to values of neighborhood elements.

 

 

2. Read and query XML via XElement

In case of reading via XElement you can get non-root nodes. You may apply filters only to attribute values.