XML File
I have the sample XML file customer.xml like below.
Model
Create a model of customer to hold the below properties.
Controller
The Controller consists of one Action method.
GET operation
Inside the Index Action method, the XML file is read using the XmlDocument class object.
Then the Customer Node is selected using XPath query and a loop is executed over all the selected Nodes.
View
Inside the View, in the very first line the Customer class is declared as IEnumerable which specifies that the Model will be available as a Collection.
The WebGrid is initialized with the Model i.e. IEnumerable collection of Customer class objects as source.
Output
The output like below,
</> Find the Source Code in Github
Summary
Post a Comment