java使用dom4j解析xml

<?xml version="1.0" encoding="GBK"?>
<GameChargeResponse>
<gameProductList>
<GameProduct>
<gameid>aaa</gameid>
<gamename>bbb</gamename>
<prodid>ccc</prodid>
<mename>ddd</mename>
<parvalue>eee</parvalue>
<finaprice>fff</finaprice>
</GameProduct>
</gameProductList>
</GameChargeResponse>

Document document = DocumentHelper.parseText(responseText);
Element products = document.getRootElement();//GameChargeResponse
for (Iterator iter = products.elementIterator(); iter.hasNext();) {
Element element = (Element) iter.next();//gameProductList
if("status".equals(element.getName()) || "message".equals(element.getName())){
continue;
}
for(Iterator ite = element.elementIterator(); ite.hasNext();){
Element ele1 = (Element) ite.next();//GameProduct
List<Element> list3 = ele1.elements();





你可能感兴趣的:(java,xml)