Create simple XML with MarkupBuilder


/ Published in: Groovy
Save to your folder(s)



Copy this code and paste it in your HTML
  1. def fw = new FileWriter("/somepath/persons.xml" )
  2. // to write to standard out, remove fw
  3. def xml = new groovy.xml.MarkupBuilder(fw)
  4.  
  5. xml.content() {
  6. xml.parameter(x:0)
  7. xml.person(id:100){
  8. firstname("John")
  9. lastname("Long")
  10. }
  11. xml.person(id:101){
  12. firstname("Ken")
  13. lastname("Smith")
  14. }
  15. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.