2011-12-20 4 views

risposta

5

Chiamare lo attributes() sull'elemento che contiene l'attributo e quindi chiamare remove('attr name') come illustrato di seguito.

attributes().remove('attr name') 

Qui puoi leggere maggiori dettagli.

+0

Ah, non ho potuto vedere il metodo attributes() nella documentazione. Grazie per il puntatore e anche vedere il metodo finale che mi è venuto in mente. –

2
/** 
* Remove all attributes from the root body tag 
*/ 
def removeBodyAttributes() { 
    def attributeNames = bodyXml.attributes().collect {it.key} 
    println attributeNames 
    println bodyXml.attributes() 
    attributeNames.each {bodyXml.attributes().remove(it)} 
    println bodyXml.attributes() 
} 
Problemi correlati