Finally, it worked. As a matter of fact, the above method is working fine. The only issue was that the string must be escaped for XML.I add the following code, and I can now see the XML:<%@page import="org.apache.commons.lang3.StringEscapeUtils" %>...String theString = IOUtils.toString(ris, Charset....