setTextContent编辑XML文件内容没变化
Java code:
/**
* 设置指定的元素名和节点索引所对应节点的内容
* @param 元素名
* @param 节点索引
* @param 内容
*/
public void setElementContent(String elementName,int nodeIndex,String newContext){
try{
NodeList nodeList=doc.getElementsByTagName(elementName);
Node node0=nodeList.item(nodeIndex);
node0.setTextContent(newContext);
}catch(DOMException e){
System.out.println(e.toString().replaceAll("\n", ""));
}
public static void setParmeter(String xmlPath,HashMap indexHP, HashMap valueHP){
XmlDocumentManager xml=new XmlDocumentManager(xmlPath);
xml.setElementContent("property", Integer.parseInt(indexHP.get("dialect").toString()), valueHP.get("dialect").toString());
xml.setElementContent("property", Integer.parseInt(indexHP.get("driver").toString()), valueHP.get("driver").toString());
xml.setElementContent("property", Integer.parseInt(indexHP.get("url").toString()), valueHP.get("url").toString());
xml.setElementContent("property", Integer.parseInt(indexHP.get("username").toString()), valueHP.get("username").toString());
xml.setElementContent("property",
相关问答:
我是利用axiom对xml进行解析!
但却出现下面的错误!
Exception in thread "main" org.apache.axiom.om.OMException: [com.ctc.wstx.exc.WstxLazyException] com.ctc.wstx.exc.WstxUnexpectedCharEx ......
DataSet导出xml 批处理(循环)得怎么处理
XML文件
<A>
<B>
<C>
</C>
&nb ......
HTML code:
<div id="tessx">
<ALEXA VER="0.9" URL="163.com/" HOME="0" AID="=">
<RLS PREFIX="http://" more="79" ......
如何用c++程序判断xml中各元素的合法性,针对格式上的合法性,返回0或者1
使用MSXML,加载XML后,使用validate方法验证
据说你要在linux下使用。
linux下可以使用Libxml2来操作xml,同样提供了validate的方法 ......
今天遇到一个问题,把xml中的值装到.txt格式的文件中。
我目前想到两种比较笨的方法:1.可以通过xmlspy编辑工具实现
2.通过把xml转成Javabean,然后转到excel中,再从新保存重命名为. ......