如果是用的是jdom
Reader in = new StringReader("你的xml路径");
Document doc = builder.build(in);
Element root = doc.getRootElement();//获取root
List list=root.getChildren();
for(int i=0;i<list.size();i++){
Element childNode=(Element)list.get(i);
//获取属性用getAttributeValue
String type=childNode.getAttributeValue("type");
}
Reader in = new StringReader("你的xml路径");
Document doc = builder.build(in);
Element root = doc.getRootElement();//获取root
List list=root.getChildren();
for(int i=0;i<list.size();i++){
Element childNode=(Element)list.get(i);
//获取属性用getAttributeValue
String type=childNode.getAttributeValue("type");
}
解决方案 »
- 奇怪,为什么html中form的method是get,为什么我最后提交数据时地址栏没有显示数据,不是post没有吗?
- 请高手指点啊……java中双色球实现过程
- 用DIV打印报表
- 幫找我的寫法到底是錯在哪里了?
- 关于------------ radio -----------的困惑
- Lomboz3.1中如何开发CMP?
- 有没有做过网上证券交易与管理系统的朋友,能不能提供些有用的资料。
- spring+hibernate“列名无效”的错误
- 谁有htmlunit测试的实例,重谢
- 请大家帮忙推荐几本中文的JBOSS或者STRUTS参考书
- JSP开发我想用Fileupload多文件上传,但又要生成缩略图,多文件不好取出,怎么办呢?
- spring+hibernate+struts2.0中的hibernateTemplate的问题
不过
String type=childNode.getAttributeValue("type");
中type的值在执行中不是会被覆盖掉了、
String[] type;
for(int i=0;i<list.size();i++){
……
type[i] = childNode.getAttributeValue("type");
}
我也不知道是否对。但是感觉那样写会丢东西。
我是新手,对与XML不熟悉,没有接触过。
谢谢你的提示