6
일부 구문 분석 된 HTML (XML로 변환 됨)에서 본문 노드의 특성을 제거해야합니다.Groovy의 XMLSlurper 및 GPathResult를 사용하여 노드에서 속성을 제거하는 방법은 무엇입니까?
일부 구문 분석 된 HTML (XML로 변환 됨)에서 본문 노드의 특성을 제거해야합니다.Groovy의 XMLSlurper 및 GPathResult를 사용하여 노드에서 속성을 제거하는 방법은 무엇입니까?
통화 속성을 포함하고, 아래와 같이 다음 remove('attr name')
전화 소자에 attributes()
에게.
attributes().remove('attr name')
자세한 내용은 여기를 참조하십시오.
/**
* 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()
}
아, 문서에서 attributes() 메소드를 볼 수 없습니다. 포인터 주셔서 감사 드리며 내가 생각해 낸 마지막 방법을 살펴보십시오. –