2011-12-20 1 views

答えて

5

属性を含む要素のattributes()を呼び出して、次に示すようにremove('attr name')を呼び出します。

attributes().remove('attr name') 

ここで詳細を読むことができます。

+0

ああ、私はドキュメントのattributes()メソッドを見ることができませんでした。ポインタをありがとう、また私が思いついた最後の方法を参照してください。 –

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() 
} 
関連する問題