I am trying to create a valid html document from html
String content = getContent()
def parser = new org.cyberneko.html.parsers.SAXParser()
parser.setFeature('http://xml.org/sax/features/namespaces', false)
def slurper = new XmlSlurper(parser)
def html = slurper.parseText(content)
String xml = XmlUtil.serialize(html, )
println xml
However, the output will have all the tag names in uppercase eg. HTML/BODY How do I stop it from capitalizing the tags.
Not sure, but isn't it here what You are looking for? Search for 'lower'. As far as I see You can just set it. But here is the motivation why elements are always uppercase, HTML DOM specification plays role here. It means that probably all of us code invalid HTML :D