I have XML with this format:
<message>
<message_type_id>1</message_type_id>
<message_type_code>code1</message_type_code>
<version/>
<created_at>date1</created_at>
<payload>
<payment>
<document_id>id1</document_id>
<account_id>id2</account_id>
</payment>
</payload>
</message>
Branch inside payload is not defined. In one XML it can have one structure, in other XML - another.
As a result I want a dynamic array like this:
message_type_id: 1
message_type_code: code1
created_at: date1
document_id: id1
account_id: id2
Remember, that keys "document_id" and "account_id" can have another structure with different levels of embedding. In other words, I need to parse only leaves of each XML tree. And I don't know how these leaves are called, so constructions like
root.payload.payment.document_id
aren't useful.
I tried to solve this task with XmlSlurper, but didn't successed. How can I solve this task?