欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

JDom 基本示例,JDom示例,import java.

来源: javaer 分享于  点击 7178 次 点评:40

JDom 基本示例,JDom示例,import java.


import java.io.*; import org.jdom.*; import org.jdom.input.*; import org.jdom.output.*; public class FirstRecipeJDOM {  public static void main(String[] args) {    try {      Document d = new SAXBuilder().build(new File(args[0]));       Namespace ns = Namespace.getNamespace("<a href="http://recipes.org">http://recipes.org");      Element e = new Element("collection");      e.addContent(d.getRootElement().getChild("recipe", ns).detach());      Document n = new Document(e);      new XMLOutputter().output(n, System.out);    } catch (Exception e) {e.printStackTrace();}   }}//该片段来自于http://byrx.net
相关栏目:

用户点评