2014-04-30 3 views

답변

5

:

def xml = '<racebet amount="8.89" id="6852465" bettype="K" instance="1" type="csf" />' 

당신은 간단하게 수행 할 수 있습니다

def attrmap = new XmlSlurper().parseText(xml).attributes() 
+0

와우, 중대한. XMLSlurper에 대한 설명서는 많이 부족합니다. http://groovy.codehaus.org/Reading+XML+using+Groovy's+XmlSlurper –

+0

'XmlParser'를 사용하는 경우에도 동일합니다. – dmahapatro

+0

@saravana_pc [GPathResult] (http://groovy.codehaus.org/api/groovy/util/slurpersupport/GPathResult.html) Api 또는 [Node] (http://groovy.codehaus.org/ api/groovy/util/Node.html) API 대신에 XmlSlurper가 XmlParser를 사용할 때 파싱 된 결과 중 하나이기 때문에 Api를 사용합니다. – dmahapatro