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

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

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

    Feng.Li's Java See

    抓緊時間,大步向前。
    隨筆 - 95, 文章 - 4, 評論 - 58, 引用 - 0
    數據加載中……

    使用org.w3c.dom進行 XML操作(一)

    采用org.w3c.dom進行XML操作(一)
    ?

    XMLBuilder.java

    ?用于創建DOM,Root結點

    /********************************************************************
    ?* 項目名稱????:rochoc???<p>
    ?* 包名稱? ????:rochoc.xml.oper?<p>
    ?* 文件名稱????:XmlBuilder???<p>
    ?* 編寫者 ????:luoc????<p>
    ?* 編寫日期????:2005-6-22????<p>
    ?* 程序功能(類)描述?:?根據傳入的XML文件生成Document和root結點<p>
    ?*
    ?* 程序變更日期???:
    ?* 變更作者????:
    ?* 變更說明????:
    ********************************************************************/
    package rochoc.xml.oper;

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

    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;

    import org.apache.log4j.Logger;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.xml.sax.SAXException;

    /**
    ?* 類名:XmlBuilder? <p>
    ?* 類描述:根據傳入的XML文件生成Document和root結點 <p>
    ?* 編寫者 :luoc<p>
    ?* 編寫日期 :2005-6-22<p>
    ?* 主要public成員變量:<p>
    ?* 主要public方法:?? <p>
    ?**/

    public class XmlBuilder
    {
    ??? /**
    ???? *構造函數說明:?????? <p>
    ???? *參數說明:@param path?? <p>
    ??? **/
    ??? public XmlBuilder(String path)
    ??? {
    ??????? this.path=path;
    ??????? init();
    ??? }
    ???
    ??? /**
    ??? * 方法名稱:init<p>
    ??? * 方法功能:初始化函數<p>
    ??? * 參數說明: <p>
    ??? * 返回:void <p>
    ??? * 作者:luoc
    ??? * 日期:2005-6-22
    ??? **/
    ??? public void init()
    ??? {
    ??????? buildDocument();
    ??????? buildRoot();
    ??? }
    ???
    ??? /**
    ??? * 方法名稱:buildDocument<p>
    ??? * 方法功能:將XML文件生成Document <p>
    ??? * 參數說明: <p>
    ??? * 返回:void <p>
    ??? * 作者:luoc
    ??? * 日期:2005-6-22
    ??? **/
    ??? private void buildDocument()
    ??? {
    ??????? DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
    ??????? try
    ??????? {
    ??????????? DocumentBuilder builder=factory.newDocumentBuilder();
    ??????????? logger.debug("Construct document builder success.");
    ??????????? doc=builder.parse(new File(path));???????????
    ??????????? logger.debug("Build xml document success.");
    ??????? }catch(ParserConfigurationException e)
    ??????? {
    ??????????? logger.error("Construct document builder error:"+e);
    ??????? }catch(SAXException e)
    ??????? {
    ??????????? logger.error("Parse xml file error:"+e);
    ??????? }catch(IOException e)
    ??????? {
    ??????????? logger.error("Read xml file error:"+e);
    ??????? }
    ??? }
    ???
    ??? /**
    ??? * 方法名稱:buildRoot<p>
    ??? * 方法功能:生成XML的根結點<p>
    ??? * 參數說明: <p>
    ??? * 返回:void <p>
    ??? * 作者:luoc
    ??? * 日期:2005-6-22
    ??? **/
    ??? private void buildRoot()
    ??? {
    ??????? root=doc.getDocumentElement();
    ??? }
    ???
    ??? /**
    ???? * @return 返回 doc。
    ???? */
    ??? public Document getDoc()
    ??? {
    ??????? return doc;
    ??? }
    ??? /**
    ???? * @param doc 要設置的 doc。
    ???? */
    ??? public void setDoc(Document doc)
    ??? {
    ??????? this.doc = doc;
    ??? }
    ??? /**
    ???? * @return 返回 path。
    ???? */
    ??? public String getPath()
    ??? {
    ??????? return path;
    ??? }
    ??? /**
    ???? * @param path 要設置的 path。
    ???? */
    ??? public void setPath(String path)
    ??? {
    ??????? this.path = path;
    ??? }
    ??? /**
    ???? * @return 返回 root。
    ???? */
    ??? public Element getRoot()
    ??? {
    ??????? return root;
    ??? }
    ??? /**
    ???? * @param root 要設置的 root。
    ???? */
    ??? public void setRoot(Element root)
    ??? {
    ??????? this.root = root;
    ??? }
    ??? /*全局變量*/
    ??? private String path=null;//xml文件路徑
    ??? private Document doc=null;//xml文件對應的document
    ??? private Element root=null;//xml文件的根結點
    ??? private Logger logger=Logger.getLogger(getClass().getName());
    }

    posted on 2006-12-05 23:42 小鋒 閱讀(807) 評論(0)  編輯  收藏 所屬分類: J2EE

    主站蜘蛛池模板: 黑人粗长大战亚洲女2021国产精品成人免费视频 | 亚洲视频无码高清在线| 亚洲国产成人精品无码一区二区| 亚洲综合小说另类图片动图 | 亚洲制服在线观看| 日本中文字幕免费看| 四虎影院免费在线播放| 亚洲人成网77777亚洲色| 国产特黄一级一片免费| 一本色道久久综合亚洲精品高清| 亚洲日产2021三区在线| 18禁止观看免费私人影院| 亚洲国产亚洲综合在线尤物| 99久久国产热无码精品免费| 亚洲伦理中文字幕| 国产精品成人免费一区二区| 亚洲av日韩专区在线观看| 91禁漫免费进入| 亚洲av无码片区一区二区三区| 东方aⅴ免费观看久久av| 日日AV拍夜夜添久久免费| 国产亚洲综合精品一区二区三区| 中文字幕在线观看免费视频| 亚洲国产模特在线播放| 午夜无遮挡羞羞漫画免费| 成人亚洲国产精品久久| 亚洲精品成人无限看| 91精品导航在线网址免费| 久久亚洲色一区二区三区| 99久久99久久精品免费观看| 国产精品V亚洲精品V日韩精品| 亚洲国产精品久久久久秋霞小| 最近在线2018视频免费观看| 亚洲人xxx日本人18| 91福利视频免费| 日韩在线视精品在亚洲| 精品免费国产一区二区| 国产VA免费精品高清在线| 国产一区二区三区在线观看免费| 亚洲国产精品久久网午夜| 一本色道久久88亚洲综合|