Parsing tricky xml structure

19 views
Skip to first unread message

David Stutzman

unread,
Oct 1, 2021, 5:16:28 PM10/1/21
to jackson-user
Is there any way to parse this with jackson-dataformat-xml and XmlMapper?

<Root>
   <Key>key1</Key>
   <Value>value1</Value>
   <Key>key2</Key>
   <Value>value2</Value>
   ...
</Root>

I am parsing the output of something else so I don't have control over the format.  There could be an arbitrary number of Key/Value pairs.  If I parse into a single key/value field or lists, I only end up with the last occurrence of each item in the POJO.

I'm trying to port some JAX-B parsing over to Jackson.  The existing stuff is grabbing the data as a List<org.w3c.dom.Node> using @XmlAnyElement and then processing it after to group them together.

Thanks
Reply all
Reply to author
Forward
0 new messages