Showing posts from October 12, 2011

How to process XML File in java

I had an requirement to parse an incoming SOAP Message object and do certain manipulations over it. I had to do it outside the web service route, so there was no SOAP related process methods available for me. All I had was a xml file in the Input Stream.

I searched a lots of link for xml processing, used many libraries most of which I do not even remember the  name. Then my colleague and another contributor to these blogs suggested to use the DOM Parser provided by default in java. Though it was little confusing in the beginning, with the help of couple of other blogs, we managed to complete it without any external libraries. I have attached the code and the xml file content for your reference.

XML File
Name : test.xml

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="">
        <ns2:RegisterComplaint xmlns:ns2="http://webservice/">