使用VTD-XML解析器下面我该怎么做.
With the VTD-XML parser how do I do below.
<root>
<A>
<B>
<c>1<c/>
<d>2<d/>
<e>3<e/>
</B>
<B>
<c>1<c/>
<d>2<d/>
<e>3<e/>
</B>
</A>
</root>
在上面的 xml 中,如何仅删除具有标签名称 <B> 的节点?
In the above xml how do I remove only nodes has tag name <B> ?
所以我的最终输出应该是
So my final out put should be
<root>
<A>
</A>
</root>
这是删除A的所有子节点的代码,关键是VTDNav的getContentFragment().
This is the code that removes all child nodes of A, the key is VTDNav's getContentFragment().
import com.ximpleware.*;
public class removeNode {
public static void main(String s[]) throws Exception{
VTDGen vg = new VTDGen();
boolean b = vg.parseFile("input.xml", false);
if (b==false)
return;
VTDNav vn = vg.getNav();
XMLModifier xm = new XMLModifier(vn);
vn.toElement(VTDNav.FC); // get to A node
long l = vn.getContentFragment();
xm.remove(l);
xm.output("output.xml");
}
}
这篇关于如何使用 VTD-XML 解析器删除特定节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
上传进度侦听器未触发(Google 驱动器 API)Upload progress listener not fired (Google drive API)(上传进度侦听器未触发(Google 驱动器 API))
使用 Google Drive SDK 将文件保存在特定文件夹中Save file in specific folder with Google Drive SDK(使用 Google Drive SDK 将文件保存在特定文件夹中)
Google Drive Android API - 无效的 DriveId 和 Null ResourcGoogle Drive Android API - Invalid DriveId and Null ResourceId(Google Drive Android API - 无效的 DriveId 和 Null ResourceId)
谷歌驱动api服务账户查看上传文件到谷歌驱动使Google drive api services account view uploaded files to google drive using java(谷歌驱动api服务账户查看上传文件到谷歌驱动使用java
Google Drive 服务帐号返回 403 usageLimitsGoogle Drive service account returns 403 usageLimits(Google Drive 服务帐号返回 403 usageLimits)
com.google.api.client.json.jackson.JacksonFactory;Google Drcom.google.api.client.json.jackson.JacksonFactory; missing in Google Drive example(com.google.api.client.json.jackson.JacksonFactory;Google Drive 示例