0
可以使用靜態類型的Groovy ++進行XML處理嗎?Groovy ++和XML
範例(用於測試你可以使用Groovy++ web console):
@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
我無法使'@Typed(TypePolicy.MIXED)'工作(無法解析的符號),但是刪除'@Typed package test'解決了問題 – RonK 2011-06-14 10:43:11
@ronk - 刪除用@ groov編譯的@Typed package test y而不是groovy ++ – amra 2011-06-14 10:50:25