title: problem generating well formatted xml with groovy
body: <p>I have a simple groovy script that generates xml</p>
  
  <pre><code>def builder = new groovy.xml.StreamingMarkupBuilder()
  def person1 = {
  person(id:99){
  firstname("John" )
  lastname("Smith" )
  }
  }
  def person2 = {
  person(id:100){
  firstname("Jane" )
  lastname("Doe" )
  }
  }
  def personList = {
  "person-list" {
  out &lt;&lt; person1
  out &lt;&lt; person2
  }
  }
  println builder.bind(personList)
  </code></pre>
  
  <p>However, when this xml is printed...it prints everything in one line. So output is:</p>
  
  <pre><code>&lt;person-list&gt;&lt;person id='99'&gt;test&lt;/person&gt;&lt;person id='100'&gt;&lt;firstname&gt;Jane&lt;/firstname&gt;&lt;lastname&gt;Doe&lt;/lastname&gt;&lt;/person&gt;&lt;/person-list&gt;
  </code></pre>
  
  <p>Is there a way to print this in a well formatted manner like the following?</p>
  
  <pre><code>&lt;person-list&gt;
        &lt;person id='99' &gt;
           &lt;firstname&gt;John&lt;/firstname&gt;
           &lt;lastname&gt;Smith&lt;/lastname&gt;
        &lt;/person&gt;
        &lt;person id='100' &gt;
           &lt;firstname&gt;Jane&lt;/firstname&gt;
           &lt;lastname&gt;Doe&lt;/lastname&gt;
        &lt;/person&gt;
  &lt;/person-list&gt;
  </code></pre>