我想采用以下格式的 XML,并将每个代码记录加载到我的BootStrap.groovy
. 我想保留每个代码片段的格式。
XML
<records>
<code>
<language>Groovy</language>
<snippet>
println "This is Groovy"
println "A very powerful language"
</snippet>
</code>
<code>
<language>Groovy</language>
<snippet>
3.times {
println "hello"
}
</snippet>
</code>
<code>
<language>Perl</language>
<snippet>
@foo = split(",");
</snippet>
</code>
</records>
域对象
Code {
String language
String snippet
}
BootStrap.groovy
new Code(language l, snippet: x).save()