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

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

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

    溫馨提示:您的每一次轉載,體現了我寫此文的意義!!!煩請您在轉載時注明出處http://www.tkk7.com/sxyx2008/謝謝合作!!!

    雪山飛鵠

    溫馨提示:您的每一次轉載,體現了我寫此文的意義!!!煩請您在轉載時注明出處http://www.tkk7.com/sxyx2008/謝謝合作!!!

    BlogJava 首頁 新隨筆 聯系 聚合 管理
      215 Posts :: 1 Stories :: 674 Comments :: 0 Trackbacks
    package com.dom;

    import java.io.File;
    import java.util.List;

    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.OutputKeys;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;

    import org.w3c.dom.Document;
    import org.w3c.dom.Element;

    public class DomCreateXML {

        
    public static void main(String[] args) throws Exception{
            DocumentBuilder builder
    =DocumentBuilderFactory.newInstance().newDocumentBuilder();
            Document document 
    = builder.newDocument();
            Element rootElement
    =document.createElement("root");
            
            
    for (int i = 0; i < 100; i++) {
                Element bookElement
    =document.createElement("book");
                bookElement.setAttribute(
    "id", (i+1)+"");
                
                Element nameElement
    =document.createElement("name");
                nameElement.setTextContent(
    "Spring");
                
                Element priceElement
    =document.createElement("price");
                priceElement.setTextContent(
    "88");
                
                Element authorElement
    =document.createElement("author");
                authorElement.setTextContent(
    "李剛");
                
                rootElement.appendChild(bookElement);
                bookElement.appendChild(nameElement);
                bookElement.appendChild(priceElement);
                bookElement.appendChild(authorElement);
            }
            
            document.appendChild(rootElement);
            
            TransformerFactory factory
    =TransformerFactory.newInstance();
            Transformer transformer
    =factory.newTransformer();
            transformer.setOutputProperty(OutputKeys.ENCODING, 
    "utf-8");
            transformer.transform(
    new DOMSource(document), new StreamResult(new File("d:/1.xml")));
        }

    }
    生成的xml
    <?xml version="1.0" encoding="utf-8" standalone="no"?>
    <root>
        
    <book id="1">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="2">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="3">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="4">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="5">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="6">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="7">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="8">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="9">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="10">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="11">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="12">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="13">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="14">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="15">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="16">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="17">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="18">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="19">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="20">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="21">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="22">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="23">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="24">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="25">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="26">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="27">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="28">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="29">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="30">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="31">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="32">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="33">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="34">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="35">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="36">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="37">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="38">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="39">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="40">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="41">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="42">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="43">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="44">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="45">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="46">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="47">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="48">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="49">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="50">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="51">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="52">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="53">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="54">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="55">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="56">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="57">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="58">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="59">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="60">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="61">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="62">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="63">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="64">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="65">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="66">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="67">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="68">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="69">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="70">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="71">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="72">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="73">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="74">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="75">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="76">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="77">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="78">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="79">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="80">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="81">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="82">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="83">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="84">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="85">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="86">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="87">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="88">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="89">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="90">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="91">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="92">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="93">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="94">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="95">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="96">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="97">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="98">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="99">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
        
    <book id="100">
            
    <name>Spring</name>
            
    <price>88</price>
            
    <author>李剛</author>
        
    </book>
    </root>
    posted on 2011-08-24 11:29 雪山飛鵠 閱讀(471) 評論(0)  編輯  收藏 所屬分類: javaseandroid
    主站蜘蛛池模板: 免费视频精品一区二区三区 | 久久国产乱子精品免费女 | 91高清免费国产自产拍2021| 国产福利电影一区二区三区,亚洲国模精品一区 | 日韩精品成人无码专区免费| 亚洲国产成人久久| 日韩亚洲国产高清免费视频| 亚洲午夜电影在线观看| 男男AV纯肉无码免费播放无码| 亚洲人成网站色在线观看| 免费鲁丝片一级在线观看| 黄网站色成年片大免费高清| 亚洲 小说区 图片区 都市| 无人在线观看免费高清视频| 亚洲欧洲另类春色校园网站| 成人毛片手机版免费看| 亚洲国产成人久久精品软件| 日本免费网站在线观看| 一级人做人a爰免费视频| 成人毛片免费在线观看| 中文字幕乱码亚洲无线三区| 在线观看亚洲免费| 日韩免费码中文在线观看| 中文字幕在线亚洲精品| 最近中文字幕电影大全免费版| 91在线亚洲综合在线| 亚洲精品成人片在线观看| 免费av一区二区三区| 亚洲三级中文字幕| 天堂亚洲免费视频| 国产白丝无码免费视频| 亚洲AV综合色区无码二区偷拍 | 2021精品国产品免费观看| 亚洲日韩AV一区二区三区中文| 免费萌白酱国产一区二区| 国产午夜无码精品免费看动漫| 亚洲激情视频网站| 亚洲精品视频在线看| 91热久久免费精品99| 综合一区自拍亚洲综合图区| 亚洲av午夜成人片精品网站|