<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)
      {}
     }
    }


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


    網站導航:
     
    主站蜘蛛池模板: 最近中文字幕大全免费视频| 一级一级毛片免费播放| 最近2019中文字幕免费大全5| 亚洲Av无码乱码在线观看性色| 色婷婷亚洲一区二区三区| 国内精品免费视频自在线| 亚洲色在线无码国产精品不卡| 永久免费毛片在线播放| 亚洲综合一区无码精品| 国产国产人免费视频成69大陆| 亚洲精品蜜夜内射| 波多野结衣免费视频观看| 一级毛片aa高清免费观看| 狠狠亚洲婷婷综合色香五月排名 | 亚洲精华国产精华精华液好用| 手机在线毛片免费播放| 国产精品无码亚洲一区二区三区| 国产免费怕怕免费视频观看| 免费毛片毛片网址| 亚洲乱色熟女一区二区三区丝袜| 波多野结衣免费一区视频 | 亚洲成a人片在线网站| 女人与禽交视频免费看| 国产在亚洲线视频观看| 国产aⅴ无码专区亚洲av麻豆| 可以免费观看的毛片| 亚洲国产精品yw在线观看| 麻豆国产精品入口免费观看| 美女黄色毛片免费看| 亚洲AV无码专区在线播放中文| 30岁的女人韩剧免费观看| 亚洲AV无码专区在线观看成人| 亚洲麻豆精品国偷自产在线91| 黄色网址在线免费| 亚洲综合一区无码精品| 亚洲一区二区三区香蕉| 亚洲免费福利视频| 一级做a爰黑人又硬又粗免费看51社区国产精品视 | 白白国产永久免费视频| 国产日韩AV免费无码一区二区| 一区二区亚洲精品精华液|