In this recipe, we will be building a .NET Standard 2.0 library that reads XML data using LINQ to XML. LINQ to XML is a LINQ enabled in-memory programming interface. It enables you to work with XML using your favorite .NET language. C# is used in this book to describe the code. In this recipe, we will mainly be looking at querying an XML document using LINQ to XML. We have used LINQ to XML to write to an XML file in the A library that reads and writes to an XML file recipe.
This recipe assumes you have used LINQ. We are focusing on LINQ with XML documents. Let's fire up Visual Studio and get started.
- Open Visual Studio 2017.
- Click
File
|New
|Project
to create a project.
- In the
New Project
dialog box, expand theOther Project Types
node in the left-hand pane and selectVisual Studio Solutions
. In the right-hand pane, selectBlank Solution
.
- In the
Name:
textbox, typeChapter5.XmlLinq
and, in theLocation:
textbox, select a...