How to read the hyphenated attribute names (Eg. model_name) while parsing xml using XmlSlurper
问题 I am trying to read an attribute while parsing XML using XmlSlurper in Groovy. When I try to read the hyphenated attribute model-number I am getting an exception. <router name="b" id="x" manufacturer-id="e" model-number="a"/> 回答1: def a = "<router name='b' id='x' manufacturer-id='e' model-number='a'/>" def router = new XmlSlurper().parseText(a) println router.@'manufacturer-id' println router.@'name' println router.@'id' println router.@'model-number' i tried this on console and it is working