0

I would like to get a Groovy NodeChild that represents, e.g., a body tag.

However, if I do

html=new XmlSlurper().parseText(blah)

I get html which is a NodeChild.

However html.body is a NodeChildren tag, and I can't seem to get a NodeChild.

Much help appreciated!

Thank you Misha

Миша Кошелев
  • 1,483
  • 1
  • 24
  • 41

2 Answers2

0

You could try this:

def body = html.body.'**'

From there you can query the rest of your dom tree:

def myDiv = body.find { it.@id.text() == "divId" }

You can check it by printing out the result

println myDiv.'@id'.text()
Michael D Johnson
  • 889
  • 1
  • 10
  • 21
0

This works but there must be something simpler:

def body=html.children().find { it.name()=="BODY" }

Misha

Миша Кошелев
  • 1,483
  • 1
  • 24
  • 41