Groovy 1.7.0

## groovy.xml
Class StreamingMarkupBuilder

    java.lang.Object
      groovy.xml.streamingmarkupsupport.AbstractStreamingBuilder
          groovy.xml.StreamingMarkupBuilder

    class StreamingMarkupBuilder
    extends AbstractStreamingBuilder

A builder class for creating XML markup. This implementation uses a StreamingMarkupWriter to handle output.

Example:

    new StreamingMarkupBuilder().bind {
       root {
         a( a1:'one' ) {
           b { mkp.yield( '3 < 5' ) }
           c( a2:'two', 'blah' )
         }
       }
     }.toString()

Will return the following String, without newlines or indentation:

    <root>
       <a a1='one'>
         <b>3 &lt; 5</b>
         <c a2='two'>blah</c>
       </a>
     </root>

Note that `mkp` is a special namespace used to escape away from the normal building mode of the builder and get access to helper markup methods 'yield', 'pi', 'comment', 'out', 'namespaces', 'xmlDeclaration' and 'yieldUnescaped'.

Property Summary
`def` | `builder`
`def` | `commentClosure` Invoked by calling `mkp.comment`
`def` | `declarationClosure` Invoked by calling `mkp.xmlDeclaration`
`def` | `encoding`
`def` | `noopClosure` Invoked by calling `mkp.yield`.
`def` | `pendingStack`
`def` | `piClosure` Invoked by calling `mkp.pi`
`def` | `tagClosure`
`def` | `unescapedClosure` Invoked by calling `mkp.yieldUnescaped`.

Constructor Summary
`StreamingMarkupBuilder()`

Method Summary
`def` | `bind(def closure)` Returns a { the markup directly to a String, or send the output to a stream.

Methods inherited from class Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll

Property Detail

### builder

    def builder

### commentClosure

    def commentClosure

  Invoked by calling `mkp.comment`

### declarationClosure

    def declarationClosure

  Invoked by calling `mkp.xmlDeclaration`

### encoding

    def encoding

### noopClosure

    def noopClosure

  Invoked by calling `mkp.yield`. Used to render text to the output stream. Any XML reserved characters will be escaped to ensure well-formedness.

### pendingStack

    def pendingStack

### piClosure

    def piClosure

  Invoked by calling `mkp.pi`

### tagClosure

    def tagClosure

### unescapedClosure

    def unescapedClosure

  Invoked by calling `mkp.yieldUnescaped`. Used to render literal text or markup to the output stream. No escaping is done on the output.

Constructor Detail

### StreamingMarkupBuilder

    public StreamingMarkupBuilder()

Method Detail

### bind

    public def bind(def closure)

  Returns a Writable object, which may be used to render the markup directly to a String, or send the output to a stream.

  Examples:

       // get the markup as a string:
       new StreamingMarkupBuilder.bind { div { out << "hello world" } }.toString()

       // send the output directly to a file:
       new StreamingMarkupBuilder.bind { div { out << "hello world" } } \
       	 .writeTo( new File('myFile.xml').newWriter() )

  return:
    a Writable to render the markup

Copyright © 2003-2009 The Codehaus. All rights reserved.