I have xml data looking like this:
<persons>
<person key="M">John Doe</person>
<person key="N">Jane Doe</person>
</persons>
I want to collect them into a list of maps like
[[key: M, name: John Doe], [key: N, name: Jane Doe]]
and I use, after slurping the data into the variable 'p', using XmlSlurper:
p.collect { [key: it.@key.text(), name it.text()] }
but I get
[[key: MN, name: John DoeJane Doe]]
Obviously I do something very wrong, but I can't figure out what. I have tried a number of methods but get the same answer.