开发者

NodeList value does not get updated?

This statement simply would not update the value of the node in question! Could you please tell me why this is the case or if I'm doing something wrong here?!?

for (int i = 0; i < list.getLength();开发者_如何学运维 i++) {
  temp = list.item(i).toString();
  System.out.println(temp.substring(temp.indexOf("\"")+1, temp.lastIndexOf("\"")));
  list.item(i).setNodeValue(temp.substring(temp.indexOf("\"")+1, temp.lastIndexOf("\"")));
  System.out.println(list.item(i));
}

Thanks


Please check this link:

Node Javadoc http://download.oracle.com/javase/1.4.2/docs/api/org/w3c/dom/Node.html#setNodeValue(java.lang.String)

You can see why your code doesn't work. Your node should be 'attribute' to get/set its value. Probably in your case list.item(i) refers to an 'element' type and that's why it doesn't work. You should traverse (go to child) until you find an attribute type.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜