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

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

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

    靈魂-放水

    為學日益,為道日損。

    BlogJava 首頁 新隨筆 聯系 聚合 管理
      296 Posts :: 10 Stories :: 274 Comments :: 0 Trackbacks

    ?程序代碼片-類方法:用到jdom包
    public void removeElement(String path,String catalog){
    ???????SAXBuilder sb = new SAXBuilder();
    ?? try
    ????? {???????
    ?????? Document doc = sb.build(path);
    ?????? Element root = doc.getRootElement();
    ?????? Element subroot=root.getChild("entity");
    ??????
    ?????? Element content=subroot.getChild("contents");
    ??? ?
    ??? ? List entities=content.getChildren("entity");
    ??? ? for(int j=0;j<entities.size();j++)
    ??? ? {
    ??? ?? Element _element=(Element)entities.get(j);
    ??? ?? if(_element.getChild("nick").getText().equals(catalog))
    ??? ?? {
    ??? ??? System.out.println(_element.getChild("nick").getText());
    ??? ??? System.out.println(_element.getChild("description").getText());
    ?????? ??? content.removeContent(_element);
    ?????????? //_element.removeContent(_element);
    ?????????? }
    ??? ? }
    ??????
    ???????? Format format = Format.getCompactFormat();

    ???????? format.setEncoding("UTF-8"); //設置xml文件的字符為UTF-8
    ???????? format.setIndent("??? "); //設置xml文件的縮進為4個空格

    ???????? XMLOutputter xmlOutput = new XMLOutputter(format);
    ???????? xmlOutput.output(root, new FileOutputStream(path));
    ????? }
    ??? catch(Exception e)
    ??? {
    ????????? e.printStackTrace();
    ??? }
    ???? }
    XML文件片:
    ?<entity>
    ??????? <description>文檔目錄管理</description>
    ??????? <imageBase>images/globe.gif</imageBase>
    ??????? <imageOpen>images/globe_selected.gif</imageOpen>
    ??????? <contents>
    ??????????? <entity>
    ??????????????? <nick>1</nick>
    ??????????????? <description>檔案管理程序</description>
    ??????????????? <imageBase>images/book.gif</imageBase>
    ??????????????? <imageOpen>images/bookOpen.gif</imageOpen>
    ??????????????? <contents>
    ??????????????????? <entity>
    ??????????????????????? <nick>1</nick>
    ??????????????????????? <description>國家Linux技術培訓與推廣中心檔案查詢登記表</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術培訓與推廣中心檔案查詢登記表</title>
    ??????????????????????? <dir>doc/1/1.doc</dir>
    ??????????????????? </entity>
    ??????????????????? <entity>
    ??????????????????????? <nick>2</nick>
    ??????????????????????? <description>國家Linux技術培訓與推廣中心檔案管理程序</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術培訓與推廣中心檔案管理程序</title>
    ??????????????????????? <dir>doc/1/2.doc</dir>
    ??????????????????? </entity>
    ??????????????????? <entity>
    ??????????????????????? <nick>3</nick>
    ??????????????????????? <description>lnic人員管理辦法</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>lnic人員管理辦法</title>
    ??????????????????????? <dir>doc/1/3.txt</dir>
    ??????????????????? </entity>
    ??????????????? </contents>
    ??????????? </entity>
    ??????????? <entity>
    ??????????????? <nick>2</nick>
    ??????????????? <description>對外業務</description>
    ??????????????? <imageBase>images/book.gif</imageBase>
    ??????????????? <imageOpen>images/bookOpen.gif</imageOpen>
    ??????????????? <contents>
    ??????????????????? <entity>
    ??????????????????????? <nick>1</nick>
    ??????????????????????? <description>國家Linux技術培訓與推廣中心供應商調查報告</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術培訓與推廣中心供應商調查報告</title>
    ??????????????????????? <dir>doc/2/1.doc</dir>
    ??????????????????? </entity>
    ??????????????????? <entity>
    ??????????????????????? <nick>2</nick>
    ??????????????????????? <description>國家Linux技術培訓與推廣中心國有資產申購單</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術培訓與推廣中心國有資產申購單</title>
    ??????????????????????? <dir>doc/2/2.doc</dir>
    ??????????????????? </entity>
    ??????????????????? <entity>
    ??????????????????????? <nick>3</nick>
    ??????????????????????? <description>國家Linux技術培訓與推廣中心合格供應商名錄</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術培訓與推廣中心合格供應商名錄</title>
    ??????????????????????? <dir>doc/2/3.doc</dir>
    ??????????????????? </entity>
    ??????????????????? <entity>
    ??????????????????????? <nick>4</nick>
    ??????????????????????? <description>國家Linux技術培訓與推廣中心進貨質量驗收計劃</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術培訓與推廣中心進貨質量驗收計劃</title>
    ??????????????????????? <dir>doc/2/4.doc</dir>
    ??????????????????? </entity>
    ??????????????????? <entity>
    ??????????????????????? <nick>5</nick>
    ??????????????????????? <description>國家Linux技術培訓與推廣中心培訓協議書</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術培訓與推廣中心培訓協議書</title>
    ??????????????????????? <dir>doc/2/5.doc</dir>
    ??????????????????? </entity>
    ??????????????????? <entity>
    ??????????????????????? <nick>6</nick>
    ??????????????????????? <description>國家Linux技術培訓與推廣中心外購物品驗收報告</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術培訓與推廣中心外購物品驗收報告</title>
    ??????????????????????? <dir>doc/2/6.doc</dir>
    ??????????????????? </entity>
    ??????????????????? <entity>
    ??????????????????????? <nick>7</nick>
    ??????????????????????? <description>lnic人員器材管理辦法</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>lnic人員器材管理辦法</title>
    ??????????????????????? <dir>doc/2/7.doc</dir>
    ??????????????????? </entity>
    ??????????????? </contents>
    ??????????? </entity>
    ????????錯誤出現在: 1、content.removeContent(_element);
    ??????????2、 //_element.removeContent(_element);

    用第2種方法總達不到效果,搞了半天才更正了錯誤。

    posted on 2006-05-25 18:22 放水老倌 閱讀(397) 評論(0)  編輯  收藏 所屬分類: XML
    主站蜘蛛池模板: 亚洲一区精品无码| 国产区卡一卡二卡三乱码免费| 无码欧精品亚洲日韩一区夜夜嗨 | 亚洲伊人久久精品影院| 无码的免费不卡毛片视频| 亚洲一区二区三区国产精品| 九九综合VA免费看| 亚洲人成在线播放网站| 国产免费阿v精品视频网址| 久久精品国产亚洲av四虎| 久久一区二区三区免费播放 | 免费人妻精品一区二区三区| 免费女人18毛片a级毛片视频| 美女视频黄视大全视频免费的| 亚洲Av无码国产情品久久 | A国产一区二区免费入口| 亚洲国产精品无码av| 免费A级毛片无码A∨中文字幕下载| 亚洲黄色在线播放| 成人午夜视频免费| gogo免费在线观看| 亚洲国产天堂在线观看| 国产精品久久久久久久久久免费 | 亚洲人成在线观看| 真人做人试看60分钟免费视频| 在线观看亚洲AV每日更新无码| 国产公开免费人成视频| 久久免费精品一区二区| 亚洲日本久久一区二区va| 免费人成无码大片在线观看| a毛片在线看片免费| 亚洲性色高清完整版在线观看| 又粗又硬免费毛片| 97精品免费视频| 国产精品亚洲专区在线播放| 亚洲AV无码久久精品色欲| 女人18毛片水最多免费观看| 国产黄片不卡免费| 亚洲国产成人久久精品app| 亚洲AV网站在线观看| 亚洲免费网站在线观看|