...
| Code Block | ||||
|---|---|---|---|---|
| ||||
// create a builder, (note: this is not in one of the packages that are automatically imported def builder = new groovy.xml.MarkupBuilder() // construct a builder step(1) // create a simple xml markup builder.stocks { // step (2) stock(symbol: 'JAVA') // step (3-1) stock(symbol: 'MSFT') // step (3-2) stock(symbol: 'IBM' ) } ==== result output =====> <stocks> <stock symbol='JAVA' /> <stock symbol='MSFT' /> <stock symbol='IBM' /> </stocks> |
...
step(2) - we invoke the method stocks on builder
The first thing to note is that builder does not know the method stocks so in java for example the compiler will give an error. In a dynamic language, where these decisions are made at runtime, the builder will missing method exception.
...