我有一个xml内容作为字符串如何将其传递给jaxb解析器以填充pojo类
<?xml version="1.0" encoding="UTF-8"?><breakfast_menu<food>
<name>Belgian Waffles</name><food>
答案 0 :(得分:0)
要传递XML内容,您需要将内容包装在Reader中,然后将其解组:
JAXBContext jaxbContext = JAXBContext.newInstance(Person.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
StringReader reader = new StringReader(&#34; xml string here&#34;); 人人=(人)unmarshaller.unmarshal(读者);