当前位置: 代码迷 >> J2EE >> hash map插入数据的有关问题
  详细解决方案

hash map插入数据的有关问题

热度:608   发布时间:2016-04-22 02:39:35.0
hash map插入数据的问题
for (int a = 0; a < root.getAttributes().getLength(); a++) {
 
  System.out.println("============="+root.getAttributes().item(a).getNodeName()
  + "---" + root.getAttributes().item(a).getNodeValue());
  这段代码后面我该添加hash map的什么方法才能是添加得到的nodename和dodevalue呢 put方法好像都是插入写死的,在线等


------解决方案--------------------
你循环把得到name跟value放到2个变量里面,然后动态存到map里面去不就是了 
map.put(name,value);
------解决方案--------------------
那你XML文件的格式总归是固定的吧。
------解决方案--------------------
就这样了啊。
map.put(root.getAttributes().item(a).getNodeName()),root.getAttributes().item(a).getNodeValue());
)
------解决方案--------------------
探讨

就这样了啊。
map.put(root.getAttributes().item(a).getNodeName()),root.getAttributes().item(a).getNodeValue());
)