读书人

hash map插入数据的有关问题

发布时间: 2012-01-18 00:23:26 作者: rapoo

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());
)

读书人网 >J2EE开发

热点推荐