tags:

views:

33

answers:

1
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 { [email protected]()}.each { div ->
   println div.text()
}

This code print only Test1! How ignore case for attribute @tags?

+2  A: 

Something like this should work:

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

As you can see, you need to manually search the attribute names for a match ignoring the case

tim_yates