title: How to parse soap string in java
body: <p>I have written the below code to parse a string in java but its not printing out a blank message.</p>
  
  <p>How can I get specific parts from a SOAP message and get their values?
  I want to get the error and the message in the request.</p>
  
  <pre><code>String xml = "&lt;?xml version='1.0' encoding='UTF-8'?&gt;"
               + "&lt;S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"&gt;"
               + "&lt;S:Body&gt;"
               + "&lt;ns2:processResponse xmlns:ns2=\"http://ws.xxxxx.com/\"&gt;"
               + "&lt;response&gt;&lt;direction&gt;response&lt;/direction&gt;"
               + "&lt;reference&gt;09FG10021008111306320&lt;/reference&gt;"
               + "&lt;amount&gt;0.0&lt;/amount&gt;"
               + "&lt;totalFailed&gt;0&lt;/totalFailed&gt;"
               + "&lt;totalSuccess&gt;0&lt;/totalSuccess&gt;"
               + "&lt;error&gt;1&lt;/error&gt;"
               + "&lt;message&gt;Invalid&lt;/message&gt;"
               + "&lt;otherReference&gt;6360e28990c743a3b3234&lt;/otherReference&gt;"
               + "&lt;action&gt;FT&lt;/action&gt;"
               + "&lt;openingBalance&gt;0.0&lt;/openingBalance&gt;"
               + "&lt;closingBalance&gt;0.0&lt;/closingBalance&gt;"
               + "&lt;/response&gt;"
               + "&lt;/ns2:processResponse&gt;"
               + "&lt;/S:Body&gt;"
               + "&lt;/S:Envelope&gt;\n";
  
           SAXBuilder builder = new SAXBuilder();
              Reader in = new StringReader(xml);
              Document doc = null;
              Element root = null;
              Element meta = null;
              Element error = null;
              Element status_message = null;
              String status_code= "";
              String message = "";
              try
              {
               doc = builder.build(in);
               root = doc.getRootElement();
               meta = root.getChild("processResponse").getChild("response");
               error = meta.getChild("error");
               status_message = meta.getChild("message");
               status_code = error.getText();
               message = status_message.getText();
  
              }catch (Exception e)
               {
               // do what you want
               }
              System.out.println("status_code: " + status_code + "\nmessage: " + message);
  </code></pre>
  
  <p>The response being generated is
  status_code: 
  message: </p>