Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import groovy.xml.MarkupBuilder
  2.  
  3. /**
  4. * Produces xml file that has no whitespace character.
  5. *
  6. * new IndentPrinter(out, "", false) section does all things we need to do.
  7. *
  8. * Example output:
  9. * <products><product><title>product title</title><price>100</price></product></products>
  10. *
  11. */
  12. def writeXMLWithoutWhitespaces(String filePath) {
  13. new File(filePath).withWriter { out ->
  14. MarkupBuilder xml = new MarkupBuilder(new IndentPrinter(out, "", false))
  15. xml.products {
  16. product {
  17. title("product title")
  18. price("100")
  19. }
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement