您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

往xml中更新节点的ajax方式

2025/6/7 0:22:57发布29次查看
这次给大家带来往xml中更新节点的ajax方式,往xml中更新节点ajax的注意事项有哪些,下面就是实战案例,一起来看一下。
往xml中更新节点的实例代码
/* system.out.println(2323); documentbuilderfactory factory = documentbuilderfactory.newinstance(); documentbuilder docbuilder = factory.newdocumentbuilder(); document parse = docbuilder .parse(new file(src/prodquery.xml)); // element createelement2 = parse.createelement(); element createelement = parse.createelement(products); node item2 = parse.getchildnodes().item(parse.getchildnodes().getlength()-1); for (string item : map.keyset()) { //循环添加至products system.out.println(tianjia1); element clidren = parse.createelement(product); attr createattribute = parse.createattribute(name); createattribute.setnodevalue(item); attr createattribute2 = parse.createattribute(value); createattribute2.setnodevalue(map.get(item)); clidren.setattributenode(createattribute); clidren.setattributenode(createattribute2); createelement.appendchild(clidren); } //将products添加到根目录 item2.appendchild(createelement); //创建一个transformerfactory对象 transformerfactory tfactory = transformerfactory.newinstance(); //得到一个操作对象 transformer transformer = tfactory.newtransformer(); //设置们,这个是编码 transformer.setoutputproperty(outputkeys.encoding, utf-8); // domsource source = new domsource(parse); system.out.println(改变文件); streamresult result = new streamresult(new file(src/prodquery.xml)); //让xml文件换行 transformer.setoutputproperty(outputkeys.indent, yes); transformer.setoutputproperty({http://xml.apache.org/xslt}indent-amount, 4); transformer.transform(source, result);*/
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
ajax的restful接口传输json数据的方法
ajax+struts2怎么实现用户输入验证码校验功能
以上就是往xml中更新节点的ajax方式的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product