Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import groovy.xml.MarkupBuilder
- /**
- * Produces xml file that has no whitespace character.
- *
- * new IndentPrinter(out, "", false) section does all things we need to do.
- *
- * Example output:
- * <products><product><title>product title</title><price>100</price></product></products>
- *
- */
- def writeXMLWithoutWhitespaces(String filePath) {
- new File(filePath).withWriter { out ->
- MarkupBuilder xml = new MarkupBuilder(new IndentPrinter(out, "", false))
- xml.products {
- product {
- title("product title")
- price("100")
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement