### Question:
JAXBUtil { public <T> T xml2Obj(String xmlSource, Class<T> clazz) throws JAXBException { JAXBContext context; context = JAXBContext.newInstance(clazz); Unmarshaller unmarshal = context.createUnmarshaller(); T obj = (T) unmarshal.unmarshal(new StringReader(xmlSource)); return obj; } private  JAXBUtil(); static JAXBUtil getInstance(); String obj2Xml(Object obj); T xml2Obj(String xmlSource, Class<T> clazz);  }### Answer:
@Test void xml2Obj() throws JAXBException { String xmlSource = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<persons>\n" + " <person>\n" + " <dsaa>123</dsaa>\n" + " <dsaa>123</dsaa>\n" + " <dsaa>123</dsaa>\n" + " <dsaa>123</dsaa>\n" + " <name>xiaoming/name&gt;aadsadsa]</name>\n" + " <sex>nam</sex>\n" + " </person>\n" + " <person>\n" + " <dsaa>123</dsaa>\n" + " <dsaa>123</dsaa>\n" + " <dsaa>123</dsaa>\n" + " <dsaa>123</dsaa>\n" + " <name>xiaoming/name&gt;aadsadsa]</name>\n" + " <sex>nam</sex>\n" + " </person>\n" + " <person>\n" + " <dsaa>123</dsaa>\n" + " <dsaa>123</dsaa>\n" + " <dsaa>123</dsaa>\n" + " <dsaa>123</dsaa>\n" + " <name>xiaoming/name&gt;aadsadsa]</name>\n" + " <sex>nam</sex>\n" + " </person>\n" + " <person>\n" + " <dsaa>123</dsaa>\n" + " <dsaa>123</dsaa>\n" + " <dsaa>123</dsaa>\n" + " <dsaa>123</dsaa>\n" + " <name>xiaoming/name&gt;aadsadsa]</name>\n" + " <sex>nam</sex>\n" + " </person>\n" + "</persons>"; Person1 person1 = JAXBUtil.getInstance().xml2Obj(xmlSource,Person1.class); System.out.println(); }