How to recursively add a child inside StreamingMarkupBuilder

TheJK

New Member
I need to build a tree structure in xml where child element can have another child inside. Number of nested nodes is not specified. So I am using StreamingMarkupBuilder :\[code\]def rootNode = ....def xml = builder.bind { "root"(type:"tree", version:"1.0") { type(rootNode.type) label(rootNode.label) "child-components" { rootUse.components.each { comp -> addChildComponent(comp,xml) } } }\[/code\]But I have problem creating proper addChildComponent method. Any ideas ?Edit : Ok I made it so :\[code\]def addChildComponent {comp,xml -> xml.zzz(){ "lala"() }}\[/code\]but now I have problem with namespaces as I get : \[code\]<child-components><xml:zzz> <lala/></xml:zzz><xml:zzz> <lala/></xml:zzz><xml:zzz> <lala/></xml:zzz></child-components>\[/code\]thx
 
Back
Top