xml 转对象

前端之家收集整理的这篇文章主要介绍了xml 转对象前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Result result=null;
try {
JAXBContext context = JAXBContext.newInstance(Result.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
result = (Result)unmarshaller.unmarshal(new StringReader(xmlStr));

} catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();

}


@XmlAccessorType(XmlAccessType.FIELD) @XmlRootElement(name="xxxx") public class Result { @XmlElement(name = "PT_Id") private Integer ptId; @XmlElement(name = "Is_Success") private Boolean isSuccess; @XmlElement(name = "Message") private String message; @XmlElementWrapper(name = "Records") @XmlElements(value = { @XmlElement(name = "Record",type = Record.class) }) private List<Record> lsQiYe;

原文链接:https://www.f2er.com/xml/295428.html

猜你在找的XML相关文章