我用的是JDK1.5开发,读取XML用到了
- Java code
Node result = nodes.item(i); if (result.getNodeType() == Node.ELEMENT_NODE && result.getNodeName().equals(nodeName)) { resultNum= result.getTextContent(); result.setTextContent("写入值"); }
我调试 没有任何问题,但是发布成JDK1.4,启动服务时候 会读取XML的值,报错了,服务起不来,对应错误是:
java.lang.NoSuchMethodError: org.w3c.dom.Node.getTextContent();
运行的时候,会写入的,写入的时候应该也会报错:
java.lang.NoSuchMethodError: org.w3c.dom.Node.SetTextContent();
所以请问在1.4的下面 怎么实现读写XML节点的值呢?
------解决方案--------------------------------------------------------
getNodeValue() setNodeValue(String nodeValue)
------解决方案--------------------------------------------------------
result.getFirstChild().getNodeValue() 试试