DOM4j生成xml
来源:互联网 发布:java面向对象知识点 编辑:程序博客网 时间:2024/06/08 16:41
public class Xmltest { public static void main(String[] args) { //获取document对象 Document document2=DocumentHelper.createDocument(); //获取根元素 以此为开始增加xml元素 Element e_China=DocumentHelper.createElement("China"); //向下添加一个元素 Element pro=e_China.addElement("provice"); pro.addText("北京"); //添加内容 //添加属性元素 Element name=pro.addElement("name"); name.addText("北京"); Element num=pro.addElement("num"); num.addText("10010"); //把根元素节点设置到document上,创建文档 document2.setRootElement(e_China); try { //创建一个文件输出流 FileOutputStream fileOutputStream=new FileOutputStream(new File("palce.xml")); try { 创建一个xmlwriter对象,把文档对象写出问xml文件 XMLWriter writer=new XMLWriter(fileOutputStream); try { writer.write(document2); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
生成的xml文件
阅读全文
0 0
- dom4j 生成xml
- dom4j生成xml文件
- Dom4j 生成XML
- dom4j-生成XML字符串
- DOM4J生成XML文档
- dom4j生成xml方法
- Dom4j生成xml
- dom4j生成XML
- dom4j生成xml方法
- 利用dom4j生成XML
- dom4j生成xml文件
- dom4j生成xml文件
- dom4j 生成xml文件
- dom4j生成/解析XML
- dom4j生成xml方法
- dom4j 生成xml文件
- dom4j生成xml方法
- dom4j 生成 xml
- 121. Best Time to Buy and Sell Stock
- uboot网络验证
- jQuery中的事件与动画
- 575. Distribute Candies
- js正则对于输入框的常用限制
- DOM4j生成xml
- 基于TCP的socket编程
- hibernate实体类属性应该使用int还是Integer
- #ifdef __cplusplus extern "C" { #endif 什么意思?
- 远程模式安装Apache Hive
- linux下source命令使用详解
- js正则表达式深入
- 自定义input[type="radio"]的样式
- Redis Master Slave + sentinel