<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 0, comments - 77, trackbacks - 0, articles - 356
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    用jdom操縱xml文檔例子

    Posted on 2007-05-27 11:03 semovy 閱讀(269) 評論(0)  編輯  收藏 所屬分類: XML相關

    package com.semovy.test;

    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;

    import org.jdom.Document;
    import org.jdom.Element;
    import org.jdom.output.XMLOutputter;

    public class Test {

     /**
      * @param args
      */
     public static void main(String[] args) {
      // TODO Auto-generated method stub
      //System.out.print(new MD5().getMD5ofStr(""));
      sampleJDom();
     }
       /*
        * jdom
        */
     public static void sampleJDom()
     {
      //新建文檔對象
      Document doc = new Document();
      //新建根節點
      Element book = new Element("book");
      book.setAttribute("title", "Programming with Ajax");
      Element chapter1 = new Element("chapter");
      chapter1.setAttribute("name", "Chapter1 About Ajax");
      Element chapter2 = new Element("chapter");
      chapter2.setAttribute("name", "Chapter2 B/S Structure");
      Element section1 = new Element("section");
      section1.addContent("What is Ajax?");
      Element section2 = new Element("section");
      section2.addContent("Definiens of Ajax");
      Element section3 = new Element("section");
      section3.addContent("HTTP Protocal");
      Element section4 = new Element("section");
      section4.addContent("Web Design");
      //將子節點加入到父節點
      chapter1.addContent(section1);
      chapter1.addContent(section2);
      chapter2.addContent(section3);
      chapter2.addContent(section4);
      book.addContent(chapter1);
      book.addContent(chapter2);
      doc.addContent(book);
      //將文檔輸出到控制臺
      XMLOutputter outputter = new XMLOutputter();
      try
      {
       outputter.output(doc, new FileOutputStream(new File("c:/a.xml")));
       System.out.println("輸出到文件成功!");
       outputter.output(doc, System.out);
       System.out.println("輸出到控制臺!");
      }catch(IOException ex)
      {}
     }
    }


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 日批视频网址免费观看| 国产极品美女高潮抽搐免费网站| 亚洲成a人片在线观看日本麻豆| 亚洲黄色网址在线观看| 中美日韩在线网免费毛片视频 | 亚洲色偷偷狠狠综合网| 自拍日韩亚洲一区在线| 一级毛片aaaaaa免费看| 国产亚洲精品资在线| 亚洲av色香蕉一区二区三区 | 一级做a爱过程免费视| 免费爱爱的视频太爽了| 亚洲高清不卡视频| 免费看成人AA片无码视频吃奶| 免费在线不卡视频| 亚洲人成色在线观看| **aaaaa毛片免费同男同女| 精品亚洲一区二区| 午夜肉伦伦影院久久精品免费看国产一区二区三区| 久久经典免费视频| 久久亚洲国产成人精品性色| 三年在线观看免费观看完整版中文| 国产伦一区二区三区免费| 中文字幕乱码亚洲精品一区| www视频在线观看免费| 亚洲五月六月丁香激情| 在线看片免费人成视频播| 久久久久亚洲爆乳少妇无| 色妞www精品视频免费看| 免费看无码自慰一区二区| 国产亚洲玖玖玖在线观看| 91高清免费国产自产| 久久精品国产亚洲AV香蕉| 免费精品一区二区三区第35 | 亚洲人成人网站18禁| 24小时免费直播在线观看| 亚洲伊人精品综合在合线| 99国产精品永久免费视频| 亚洲狠狠狠一区二区三区| 精品熟女少妇a∨免费久久| 亚洲邪恶天堂影院在线观看|