2010-09-02 19 views

回答

4

像這樣的東西應該工作:

def doc = """ 
<html> 
<body> 
    <div tags="1">Test1</div> 
    <div taGs="">Test3</div> 
    <div TAGS="4">Test4</div> 
</body> 
</html> 
""" 

def html = new XmlSlurper().parseText(doc) 

html.body.div.findAll { it.attributes().find { it.key.equalsIgnoreCase('tags') }.value }.each { div -> 
    println div.text() 
} 

正如你所看到的,你需要手動搜索的屬性名進行匹配忽略大小寫