public static void main(String[] args) throws DocumentException { String xml="<?xml version= '1.0' encoding='gb2312'?><weighData><weighTime>2012-12-2 12:23:12</weighTime><cardNum>2</cardNum><cfid>123</cfid></weighData>"; Document dom=DocumentHelper.parseText(xml); Element root=dom.getRootElement(); String weighTime=root.element("weighTime").getText(); String cardNum=root.element("cardNum").getText(); String cfid=root.element("cfid").getText(); System.out.println(weighTime); System.out.println(cardNum); System.out.println(cfid); }
//須要的包 dom4j.jardom