com.thoughtworks.xstream xstream ${xstream.version}
package demo;import com.thoughtworks.xstream.annotations.XStreamAlias;@XStreamAlias("data")public class XjdbBean { public Message getMessage() { return message; } public void setMessage(Message message) { this.message = message; } public XjCompares getXjCompares() { return xjCompares; } public void setXjCompares(XjCompares xjCompares) { this.xjCompares = xjCompares; } @XStreamAlias("message") private Message message; @XStreamAlias("xjCompares") private XjCompares xjCompares; @XStreamAlias("xjCompares") public static class XjCompares{ public XjCompare getXjCompare() { return xjCompare; } public void setXjCompare(XjCompare xjCompare) { this.xjCompare = xjCompare; } @XStreamAlias("xjCompare") private XjCompare xjCompare; } @XStreamAlias("xjCompare") public static class XjCompare{ @XStreamAlias("wybs") private String wybs; @XStreamAlias("message") private Message message; @XStreamAlias("yjbyrq") private String yjbyrq; @XStreamAlias("xllbCheckrs") private String xllbCheckrs; @XStreamAlias("rxrqCheckrs") private String rxrqCheckrs; @XStreamAlias("yxmcCheckrs") private String yxmcCheckrs; @XStreamAlias("ccCheckrs") private String ccCheckrs; @XStreamAlias("xjCheckrs") private String xjCheckrs; public String getXllbCheckrs() { return xllbCheckrs; } public void setXllbCheckrs(String xllbCheckrs) { this.xllbCheckrs = xllbCheckrs; } public String getRxrqCheckrs() { return rxrqCheckrs; } public void setRxrqCheckrs(String rxrqCheckrs) { this.rxrqCheckrs = rxrqCheckrs; } public String getYxmcCheckrs() { return yxmcCheckrs; } public void setYxmcCheckrs(String yxmcCheckrs) { this.yxmcCheckrs = yxmcCheckrs; } public String getCcCheckrs() { return ccCheckrs; } public void setCcCheckrs(String ccCheckrs) { this.ccCheckrs = ccCheckrs; } public String getXjCheckrs() { return xjCheckrs; } public void setXjCheckrs(String xjCheckrs) { this.xjCheckrs = xjCheckrs; } public String getWybs() { return wybs; } public void setWybs(String wybs) { this.wybs = wybs; } public Message getMessage() { return message; } public void setMessage(Message message) { this.message = message; } public String getYjbyrq() { return yjbyrq; } public void setYjbyrq(String yjbyrq) { this.yjbyrq = yjbyrq; } } @XStreamAlias("message") public static class Message{ @XStreamAlias("status") private int status; @XStreamAlias("value") private String value; public int getStatus() { return status; } public void setStatus(int status) { this.status = status; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } }}
public static void main(String[] args) { // TODO Auto-generated method stub //toXml// String xmlStr=new PersonTest().toXml(); //toBean// XjdbBean per=new PersonTest().toBean(); String xmlStr=" "+""+ ""+ " "+ "0 "+ "处理成功 "+ ""+ " "+ ""+ ""+ ""; XjdbBean person=XmlUtil.toBean(xmlStr, XjdbBean.class); System.out.println("person=firstname=="+person.getMessage().getValue()); System.out.println("person=firstname=="+person.getXjCompares().getXjCompare().getMessage().getStatus()); System.out.println("0".equals(person.getXjCompares().getXjCompare().getMessage().getStatus())); if(0==person.getXjCompares().getXjCompare().getMessage().getStatus()){ System.out.println("person=firstname=="+person.getXjCompares().getXjCompare().getYjbyrq()); } /*System.out.println("person==Friends==name1=="+person.getFriend().getName().get(0)); System.out.println("person==Pets==name2=="+person.getPet().getAnimalList().get(1).getName());*/ }"+ " "+ "40288940560cfc780156262f01a344e3 "+ ""+ " "+ "1 "+ "查询成功_无数据 "+ "201507 "+ "1 "+ "1 "+ "1 "+ "1 "+ "1 "+ "