2011-12-20 10 views

Respuesta

5

Llame al attributes() en el elemento que contiene el atributo y luego llame al remove('attr name') como se muestra a continuación.

attributes().remove('attr name') 

Puede leer más detalles aquí.

+0

Ah, no pude ver el método attributes() en la documentación. Gracias por el puntero y también veo el método final que se me ocurrió. –

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() 
} 
Cuestiones relacionadas