private static String normXML(String s) throws JDOMException, IOException {
String s2 = stripComment(s);
String s3 = stripProlog(s2);
Document d = new SAXBuilder().build(new ByteArrayInputStream(s3.getBytes()));
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
return outputter.outputString(d);
}
private static String stripComment(String s) {
return Pattern.compile("<!--(.*?)-->", Pattern.DOTALL).matcher(s).replaceAll("");
}