public class XMLTest { private static XmlMapper xmlMapper = new XmlMapper(); private static ObjectMapper objectMapper = new ObjectMapper(); @Test public void test01() throws Exception { String xml = ""; StringWriter w = new StringWriter(); JsonParser jp; try { jp = xmlMapper.getFactory().createParser(xml); JsonGenerator jg = objectMapper.getFactory().createGenerator(w); while (jp.nextToken() != null) { jg.copyCurrentEvent(jp); } jp.close(); jg.close(); } catch (Exception e) { e.printStackTrace(); } System.out.println(w.toString()); }} dogname catname
com.fasterxml.jackson.core jackson-databind ${jackson.version} com.fasterxml.jackson.core jackson-core ${jackson.version} com.fasterxml.jackson.core jackson-annotations ${jackson.version} com.fasterxml.jackson.dataformat jackson-dataformat-xml ${jackson.version}