How to handle namespaced duplicate xml tags with Jackson

aemhh

New Member
Is it possible using Jackson, to handle duplicate xml tags based off of their namespace? The code below throws a JsonMappingException : Multiple fields representing property "url"\[code\]private final ObjectMapper xmlMapper = new XmlMapper();private static final String xml = "<example xmlns:test='http://test.com/'>" + "<test:url>www.namespace.com'</test:url>" + "<url>www.url.com'</url>" + "</example>";@Testpublic void parseXml() throws Exception { Example example = xmlMapper.readValue(xml, Example.class); assert example.namespaceUrl.equals("www.namespace.com");}public static class Example { @JsonProperty("url") public String namespaceUrl; @JsonProperty("url") public String url;}\[/code\]Thanks a bunch!
 
Back
Top