`
jiava9900
  • 浏览: 86794 次
  • 性别: Icon_minigender_1
  • 来自: 天津
社区版块
存档分类
最新评论

fsdfsdfsdfsdf

    博客分类:
  • java
阅读更多
    public int modixmlfile(string filename, string newfilename) {
int returnvalue = 0;
try {
saxreader saxreader = new saxreader();
document document = saxreader.read(new file(filename));
iterator iter = document.getrootelement().elementiterator();

list fd = document.selectnodes("/books/book/title/p/a");
iterator it = fd.iterator();

while (it.hasnext()) {
element elm = (element) it.next();
system.out.println(elm.gettext());

if (elm.gettext().contains("首页")) {
system.out.println("dddddddddddddddd");

elm.getparent().remove(elm);
}

}

try {
/** 将document中的内容写入文件中 */

java.io.writer wr = new java.io.outputstreamwriter(
new java.io.fileoutputstream(newfilename), "utf-8");
document.write(wr);
wr.close();
/** 执行成功,需返回1 */
returnvalue = 1;

} catch (exception ex) {
ex.printstacktrace();
}

} catch (exception ex) {
ex.printstacktrace();
}
return returnvalue;
0
7
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics