<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 小鋒 閱讀(817) 評論(0)  編輯  收藏 所屬分類: J2EE

    主站蜘蛛池模板: 国产亚洲精品资源在线26u| 成人午夜免费福利视频| 五月天婷婷精品免费视频| 91青青国产在线观看免费| 很黄很污的网站免费| 国内精品久久久久影院免费 | 中文字幕亚洲一区二区va在线| 国产VA免费精品高清在线| 一个人晚上在线观看的免费视频| 美女扒开尿口给男人爽免费视频| 妇女自拍偷自拍亚洲精品| 国产av无码专区亚洲av毛片搜| 无码一区二区三区亚洲人妻| 老司机精品视频免费| 一级做a爰片性色毛片免费网站 | 伊人久久亚洲综合影院首页| 一本色道久久88亚洲精品综合| 亚洲日韩国产欧美一区二区三区 | 亚洲一区二区久久| 亚洲人成小说网站色| 性色av极品无码专区亚洲| 亚洲视频在线观看网址| 久久影院亚洲一区| 免费看少妇作爱视频| 免费永久国产在线视频| 亚洲第一成年免费网站| 国产精品免费电影| 中文字幕无码精品亚洲资源网| 亚洲AV无码一区二区二三区入口| 亚洲综合久久成人69| 亚洲欧美日韩综合俺去了| 国产精品成人啪精品视频免费| 久久免费观看国产精品| 又粗又大又黑又长的免费视频| 99在线在线视频免费视频观看| h在线观看视频免费网站| 日本a级片免费看| 在线精品亚洲一区二区小说| 亚洲精品成人网站在线播放| 亚洲第一第二第三第四第五第六| 中文字幕无码精品亚洲资源网久久|