Similar to the JsonReader
, XmlReader
exists for us to work with the XML data efficiently. It provides XPath kind of notation to quickly access the elements of the incoming XML data.
In this recipe, we will see how to work with the XML data and use XmlReader
to construct the model, which can be used within the application.
Make sure that you have set up your development environment by following the recipes outlined in Chapter 1.
Carry out the following steps:
Create and open a new file named
users.xml
and paste the following code into it:<?xml version="1.0" encoding="UTF-8"?> <users> <user> <id>1</id> <name>Ajit Kumar</name> <age>33</age> <phone>123-456-7890</phone> <email>[email protected]</email> <alive>true</alive> </user> <user> <id>2</id> <name>Alok...