开发者

XmlSlurper NodeChild that represents a body tag?

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开发者_StackOverflow中文版.body is a NodeChildren tag, and I can't seem to get a NodeChild.

Much help appreciated!

Thank you Misha


This works but there must be something simpler:

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

Misha


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜