Can Jackson be used to handle duplicate xml tags based on their namespace?
The following is the JsonMappingException code: several fields representing the url property
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>"; @Test public 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; }
Thanks a bunch!
source share