我在学习解析xml的时候,遇到xml文件中只有一个重复的标签 代码如下
<consumption>花园街停车场A01车位2元</consumption><consumption>花园街停车场A20车位1元</consumption><cons...
<consumption>花园街停车场A01车位2元</consumption>
<consumption>花园街停车场A20车位1元</consumption>
<consumption>花园街停车场A02车位10元</consumption>
<consumption>花园街停车场A02车位10元</consumption>
<consumption>花园街停车场A01车位7元</consumption>
<consumption>花园街停车场A01车位10元</consumption>
<consumption>花园街停车场A01车位3元</consumption>
<consumption>花园街停车场A18车位1元</consumption>
怎么解析啊? 展开
<consumption>花园街停车场A20车位1元</consumption>
<consumption>花园街停车场A02车位10元</consumption>
<consumption>花园街停车场A02车位10元</consumption>
<consumption>花园街停车场A01车位7元</consumption>
<consumption>花园街停车场A01车位10元</consumption>
<consumption>花园街停车场A01车位3元</consumption>
<consumption>花园街停车场A18车位1元</consumption>
怎么解析啊? 展开
1个回答
展开全部
使用循环,
List<Element> consumptions="上一级节点元素名称".elements("consumption");
if(consumptions!=null&&consumptions.size()>0){
for(Element price:consumptions){
Syrtem.out.println("price:"+price.getTextTrim());
}
List<Element> consumptions="上一级节点元素名称".elements("consumption");
if(consumptions!=null&&consumptions.size()>0){
for(Element price:consumptions){
Syrtem.out.println("price:"+price.getTextTrim());
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询