title: Apache Common FileUtils Read XML file into String
body: <p>I have stored SOAP XML file into local machine now to validate that XML i need to load that file and extract the XML from SOAP body to validate it.</p>
  
  <p>SOAP XML</p>
  
  <pre><code>&lt;SOAP:Envelope&gt;
      &lt;SOAP:Body&gt;
          &lt;request&gt;
               &lt;Login&gt;
                  &lt;Username&gt;abc&lt;/Username&gt;
                  &lt;Password&gt;abc&lt;/Password&gt;
               &lt;/Login&gt;
          &lt;/request&gt;
      &lt;/SOAP:Body&gt;
  &lt;/SOAP:Envelope&gt;
  </code></pre>
  
  <p>I need to extract the &lt;Login&gt; XML from above SOAP request.
  I am using FileUtils to read file into string. when i read the file using that it also read the characters like \n\t\t etc means it consider the newline and tab which is in the XML formatted file.</p>
  
  <p>i extract the child node from XML as string using below code.</p>
  
  <pre><code>InputStream requestXMLInputStream = new ByteArrayInputStream(soapRequestXML.getBytes());
  DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
  DocumentBuilder dBuilder;
  String requestXMLBody = "";
  Document doc = null;
  try {
      dBuilder = dbFactory.newDocumentBuilder();
      doc = dBuilder.parse(requestXMLInputStream);        
      NodeList requestNodeList = doc.getElementsByTagName(parentTagName);
      Node node = requestNodeList.item(0);
      DOMImplementationLS domImplLS = (DOMImplementationLS) doc.getImplementation();
      LSSerializer serializer = domImplLS.createLSSerializer();
      if(node != null &amp;&amp; node.getFirstChild() != null)
            requestXMLBody = serializer.writeToString(node.getFirstChild());
  } catch (SAXException e) {
      logger.error(e.getMessage());
  } catch (IOException e) {
      logger.error(e.getMessage());
  }catch (ParserConfigurationException e) {
      logger.error(e.getMessage());
  }
  
  return requestXMLBody;
  </code></pre>
  
  <p>How can i read an XML file in without these characters.</p>
  
  <p>Please help.</p>