可以使用静态类型的 Groovy++ 进行 XML 处理吗?
示例(您可以使用Groovy++ Web 控制台进行测试):
@Typed package test
def CAR_RECORDS = '''
<records>
<car name='HSV Maloo' make='Holden' year='2006'>
<country>Australia</country>
<record type='speed'>Production Pickup Truck with speed of 271kph</record>
</car>
</records>
'''
def records = new XmlSlurper().parseText(CAR_RECORDS)
println records.car
结果:
startup failed:
Script1.groovy: 14: Cannot find property car of class GPathResult
@ line 14, column 9.
records.car
^
1 error