This article explains how to read a XML file using the Web API.
Introduction
This article explains how to read a XML file using the Web API. Here we need to create a XML file and save it in a folder from where the Web API reads the XML and displays the record in the browser. In this tutorial I will create an "Employee.XML" file.
The data of this XML file, when displayed, appears like this:
Step 1
Create the Web API application as in the following:
Step 2
Create a model class:
Add the following code:
Step 3
Create an API controller:
Step 4
Add an Index.cshtml file using the following:
In Solution Explorer.
Select "Home" -> "Index.cshtml".
Add the following code to it:
Step 5
Execute the application:
Now see the record in XML form.
Hands on ASP.NET GridView