找到java的dom相关的API,上面的提供了你需要的所有的方法。
解决方案 »
- JavaEE RMI 实现的网络聊天室 运行时服务器端和客户端都报错,看哪位高手能帮忙解决下
- javaMail如何获取发件人用的邮件服务器软件是什么?
- 急,我的程序运行10分钟tomcat就自动关闭了,帮帮小弟。
- hibernate问题,帮忙看看啊
- socket 如何得到cookie
- 急~高分求教~~~InputStream类的read()方法有奇怪现象
- 请高手帮我看看为何我的页面会重复提交记录?我的服务是Tomcat.
- 运行jbuilder+ORACLE需要什么样的电脑配置?
- 谁有JasperReports的收费文档The JasperReports Ultimate Guide?
- !!!求助,启动服务器。。。 Error creating bean with name 'session'
- java 下有什么方法可以让一个任务在每天的某一时刻运行
- 定时执行的SERVLET 怎么写,如何配置?(中间件是WEBSPHERE 5)在线等待!!
try{
InputStream in=new FileInputStream(fileName);
SAXBuilder saxB = new SAXBuilder();
Document doc = saxB.build(in);
//取得根节点;
Element root = doc.getRootElement();
//添加节点
Element temp=new Element("MyName");
temp.setAttribute("FirstName","Jialouluo");
temp.setAttribute("LastName","Mohuluojia");
root.addContent(temp);
//删除节点
System.out.println(temp.toString());
temp=root.getChild("book");
root.removeContent(temp);
System.out.println(root.toString());
//输出XML文件格式,编码
XMLOutputter outXML = new XMLOutputter("", true, "Gb2312");
FileOutputStream out = new FileOutputStream("temp_1.xml");
outXML.output(doc, System.out); outXML.output(doc, out); out.flush();
out.close();
}catch(Exception e){
System.out.println("catch===>"+e);
;}
}
if (doc.getDocumentElement() != null){
doc.getDocumentElement().insertBefore(m, null);
}
else{
doc.appendChild(m);
}