标签:
感觉解析xml还是jdom最容易简单
带list的标签获取这个children还可以再循环,相对别的解析方式感觉比较清晰。
1 import org.jdom.Document; 2 import org.jdom.Element; 3 import org.jdom.input.SAXBuilder; 4 5 6 SAXBuilder saxBuilder = new SAXBuilder(); 7 ByteArrayInputStream stream = new ByteArrayInputStream(rs.getBytes()); 8 Reader reader = new InputStreamReader(stream, "gb2312"); 9 Document documentRS = saxBuilder.build(reader); 10 Element rootElement = documentRS.getRootElement(); 11 12 13 String orderNo = rootElement.getChild("OrderNo").getText();//获取主标签下边的子标签 14 List orderAmounts = rootElement.getChildren("OrderAmount");//获取主标签下边的list标签
标签:
原文地址:http://www.cnblogs.com/jinzhiming/p/4779243.html