JAVA - Parsing an XML file into Map using FasterXml.Jackson

Viewed 10834

I have the following XML file:

<?xml version="1.0" encoding="UTF-8"?>
<Site xmlns="bla" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  id="0" affiliations="foo" status="OPERATIONAL" color="#DB2253" updateTime="2002-12-17T09:30:47.0Z" name="GFB_0035" subject="GF">
    <location>
        <vertices Lat="41.905889" Lon="12.452019"/>
        <vertices Lat="41.905973" Lon="12.453596"/>
        <vertices Lat="41.905206" Lon="12.453707"/>
        <vertices Lat="41.905058" Lon="12.452109"/>
    </location>
</Site>

I am using FasterXml.Jackson to parse the data into a Map<String, Object> object using the following code:

XmlMapper xmlMapper = new XmlMapper();
Map<String, Object> data = xmlMapper.readValue(new File(xmlFile), Map.class);

However, when I look at the contents of the "location" field I have only one vertex instead of four (the last one).

UPDATE: The map object which I get looks like the one bellow:

{id=0, affiliations=foo, status=OPERATIONAL, color=#DB2253, updateTime=2002-12-17T09:30:47.0Z, name=GFB_0035, subject=GF, location={vertices={Lat=41.905058, Lon=12.452109}}}

Is there a way to get all four entries using FasterXml.Jackson?

1 Answers
Related