赞
踩
从官网上找来的,很简单
- import org.dom4j.Document;
- import org.dom4j.DocumentHelper;
- import org.dom4j.Element;
-
- public class Foo {
-
- public Document createDocument() {
- Document document = DocumentHelper.createDocument();
- Element root = document.addElement("root");
-
- Element author1 = root.addElement("author")
- .addAttribute("name", "James")
- .addAttribute("location", "UK")
- .addText("James Strachan");
-
- Element author2 = root.addElement("author")
- .addAttribute("name", "Bob")
- .addAttribute("location", "US")
- .addText("Bob McWhirter");
-
- return document;
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。