The problem is because of formatting the xml. I tried removing the below codetransformer.setOutputProperty(OutputKeys.INDENT, "yes");transformer.setOutputProperty(OutputKeys.STANDALONE, "no");transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");which formats the xml. Now t...