title: SoapFaultException - extract code and text
body: <p>I want to extract code and text separately from the soap fault listed below. The code that I am using (listed below xml) is printing code and text together. </p>
  
  <pre><code>&lt;env:Fault xmlns:env = "http://schemas.xmlsoap.org/soap/envelope/" xmlns:fault = "http://schemas.xmlsoap.org/soap/envelope/"&gt;
      &lt;faultcode&gt;fault:Client&lt;/faultcode&gt;
      &lt;faultstring&gt;An error occurred. Please check the detail section.&lt;/faultstring&gt;
      &lt;detail&gt;
          &lt;e:serviceFault xmlns:e = "http://xml.comcast.com/types"&gt;
              &lt;e:messages&gt;
                  &lt;e:message&gt;
                      &lt;e:code&gt;ERRORCODE-82828&lt;/e:code&gt;
                      &lt;e:text&gt;Error Message.&lt;/e:text&gt;
                  &lt;/e:message&gt;
              &lt;/e:messages&gt;
          &lt;/e:serviceFault&gt;
      &lt;/detail&gt;
  &lt;/env:Fault&gt;
  </code></pre>
  
  <p><strong>Code</strong></p>
  
  <pre><code>public void printSoapFaultClientException(SoapFaultClientException e) {
      TransformerFactory transformerFactory = TransformerFactory.newInstance();
      Transformer transformer = null;
      transformer = transformerFactory.newTransformer();
  
      DOMResult result = new DOMResult();
  
          transformer.transform(e.getSoapFault().getSource(), result);
          NodeList nl = ((Document)result.getNode()).getElementsByTagName("detail");
  
      System.out.println(" text content " + ((Element)nl.item(0)).getTextContent());
  
  }
  </code></pre>