I am trying to send XML file to one of my Servlet class and I am able to do that. Below is my XML file-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<request id="a487bd863c3e4513a7893966f8e186f1">
<app hash="sha1"/>
</request>
And following is my Servlet doPost method in which I need to parse the XML file and get id and hash value from that XML file.
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String line;
        BufferedReader br = new BufferedReader(request.getReader());
        while ((line = br.readLine()) != null) {
            System.out.println(line);
            // now here parse the line and get `id and hash value`
            // from it.
        }
    }
I am thinking what is the best way to get id and hash value from that XML file. I know one way is to parse the XML file and get the id and hash value. Is there any easy or direct way to get what I am looking for?
Any simple example will be appreciated.
 
     
    