XMLUtils { public static String omitXmlDeclaration(String xml) { if (xml.startsWith("<?xml") && xml.contains("?>")) { return xml.substring(xml.indexOf("?>") + 2).trim(); } return xml; } private  XMLUtils(); static void initialize(XmlConfigurer xmlConfigurer); static LSParser createLSParser(); static LSSerializer createLSSerializer(); static LSInput createLSInput(); static LSOutput createLSOutput(); static Node findNodeByName(Document doc, String pathExpression); static void stripWhitespaceNodes(Node element); static String getNodesPathName(Node node); static String serialize(Document doc); static String prettyPrint(String xml); static Map<String, String> lookupNamespaces(Node referenceNode); static Document parseMessagePayload(String messagePayload); static Charset getTargetCharset(Document doc); static String omitXmlDeclaration(String xml); static boolean hasXmlPayload(Message message);  }
@Test public void testOmitXmlDeclaration() throws Exception { String payload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + " <testRequest xmlns=\"http: Assert.assertEquals(XMLUtils.omitXmlDeclaration(payload), "<testRequest xmlns=\"http: Assert.assertEquals(XMLUtils.omitXmlDeclaration("<testRequest xmlns=\"http: Assert.assertEquals(XMLUtils.omitXmlDeclaration(""), ""); Assert.assertEquals(XMLUtils.omitXmlDeclaration("Test"), "Test"); }