### Question:
XmlMapper { public static <T> T fromXml(String xml, Class<T> clazz) { try { StringReader reader = new StringReader(xml); return (T) createUnmarshaller(clazz).unmarshal(reader); } catch (JAXBException e) { throw ExceptionUtil.unchecked(e); } }  static String toXml(Object root); static String toXml(Object root, String encoding); static String toXml(Object root, Class clazz, String encoding); static String toXml(Collection<?> root, String rootName, Class clazz); static String toXml(Collection<?> root, String rootName, Class clazz, String encoding); static T fromXml(String xml, Class<T> clazz); static Marshaller createMarshaller(Class clazz, String encoding); static Unmarshaller createUnmarshaller(Class clazz);  }### Answer:
@Test public void xmlToObject() { String xml = generateXmlByDom4j(); User user = XmlMapper.fromXml(xml, User.class); System.out.println("Jaxb Xml to Object result:\n" + user); assertThat(user.getId()).isEqualTo(1L); assertThat(user.getInterests()).containsOnly("movie", "sports"); }