2008-09-19 7 views

Répondre

17

Essayez les options suivantes (Groovy 1.5.6):

def doc = """ 
<html> 
    <body> 
     <div tags="1">test1</div> 
     <div>test2</div> 
     <div tags="">test3</div> 
     <div tags="4">test4</div> 
    </body> 
</html> 
""" 

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

html.body.div.findAll { [email protected]()}.each { div -> 
    println div.text() 
} 

Ce sorties:

test1 
test4 
Questions connexes