1
我使用MarkupBuilder構建XML並想知道如何在創建子節點時更新父屬性。假設構建父元素時無法計算子元素的數量。Groovy markupBuilder更新父節點
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
xml.parent(totalDuration: 'should be: some of all child duration') {
child(duration: '1')
child(duration: '2')
...
}
有沒有從子節點訪問父節點的優雅方式?
感謝 塔爾