Я использую Groovy XmlSlurper для разбора документа xhtml (или sudo xhthml), и я пытаюсь добраться до текстовых узлов документа, но не могу понять, как, вот код:
import groovy.util.*
xmlText = '''
<TEXTFORMAT INDENT="10" LEADING="-5">
<P ALIGN="LEFT">
<FONT FACE="Garamond Premr Pro" SIZE="20" COLOR="#001200" LETTERSPACING="0" KERNING="0">
Less is more! this
<FONT COLOR="#FFFF00">should be all</FONT>
the
<FONT COLOR="#00FF00"> words OR should some </FONT>
OTHER WORDS will be there?
</FONT>
</P>
</TEXTFORMAT>
'''
records = new XmlSlurper().parseText(xmlText)
records.P.FONT.children().eachWithIndex {it, index -> println "${index} - ${it}"}
Какой выводится следующий вывод:
0 - should be all
1 - words OR should some
Но я хочу, чтобы он также печатал содержимое текстовых узлов, поэтому желаемый вывод:
0 - Less is more! this
1 - should be all
2 - the
3 - words OR should some
4 - OTHER WORDS will be there?
Есть идеи?