求助各位大侠:jsp 如何删除 xml 节点
我说利用如下方法创建xml节点的:
Element newElement=new Element( "mod ");
newElement.setAttribute( "id ",randomid);
newElement.setAttribute( "column ", "2 ");
newElement.setAttribute( "name ",dl_name);
newElement.setAttribute( "status ",status);
newElement.setAttribute( "share ", "0 ");
newElement.setAttribute( "row ", "1 ");
Element newNode = new Element( "title ");
newNode.setText(title);
newElement.addContent(newNode);
newNode = new Element( "data ");
Element newNodeChild = new Element( "feedId ");
newNodeChild.setAttribute( "url ",str_url);
newNodeChild.setText( "500 ");
newNode.addContent(newNodeChild);
newElement.addContent(newNode);
root.getChildren().add(newElement);
生成的xml节点的具体内容如下;
<mod id= "884060 " column= "2 " name= "xx " status= "1 " share= "0 " row= "1 ">
<title> 平均泵效 </title>
<data>
<feedId url= "pic_ajax.jsp?dzt_id=1&zt_id=1 "> 500 </feedId>
</data>
</mod>
我想根据id或者其它参数在jsp页面删除节点如何写?请教....我是新手就只有5分了,解决后立刻给分.
[解决办法]
jdom的写法:
theElem.removeContent(XPath.selectSingleNodes(root, "//elem[@id= 'xx '] "));
[解决办法]
删除节点的话,用的是removeChild
theElem.removeChild(XPath.selectSingleNodes(root, "//elem[@id= 'xx '] "));