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

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

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

    靈魂-放水

    為學(xué)日益,為道日損。

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

    ?程序代碼片-類方法:用到j(luò)dom包
    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"); //設(shè)置xml文件的字符為UTF-8
    ???????? format.setIndent("??? "); //設(shè)置xml文件的縮進(jìn)為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技術(shù)培訓(xùn)與推廣中心檔案查詢登記表</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術(shù)培訓(xùn)與推廣中心檔案查詢登記表</title>
    ??????????????????????? <dir>doc/1/1.doc</dir>
    ??????????????????? </entity>
    ??????????????????? <entity>
    ??????????????????????? <nick>2</nick>
    ??????????????????????? <description>國家Linux技術(shù)培訓(xùn)與推廣中心檔案管理程序</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術(shù)培訓(xùn)與推廣中心檔案管理程序</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>對外業(yè)務(wù)</description>
    ??????????????? <imageBase>images/book.gif</imageBase>
    ??????????????? <imageOpen>images/bookOpen.gif</imageOpen>
    ??????????????? <contents>
    ??????????????????? <entity>
    ??????????????????????? <nick>1</nick>
    ??????????????????????? <description>國家Linux技術(shù)培訓(xùn)與推廣中心供應(yīng)商調(diào)查報告</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術(shù)培訓(xùn)與推廣中心供應(yīng)商調(diào)查報告</title>
    ??????????????????????? <dir>doc/2/1.doc</dir>
    ??????????????????? </entity>
    ??????????????????? <entity>
    ??????????????????????? <nick>2</nick>
    ??????????????????????? <description>國家Linux技術(shù)培訓(xùn)與推廣中心國有資產(chǎn)申購單</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術(shù)培訓(xùn)與推廣中心國有資產(chǎn)申購單</title>
    ??????????????????????? <dir>doc/2/2.doc</dir>
    ??????????????????? </entity>
    ??????????????????? <entity>
    ??????????????????????? <nick>3</nick>
    ??????????????????????? <description>國家Linux技術(shù)培訓(xùn)與推廣中心合格供應(yīng)商名錄</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術(shù)培訓(xùn)與推廣中心合格供應(yīng)商名錄</title>
    ??????????????????????? <dir>doc/2/3.doc</dir>
    ??????????????????? </entity>
    ??????????????????? <entity>
    ??????????????????????? <nick>4</nick>
    ??????????????????????? <description>國家Linux技術(shù)培訓(xùn)與推廣中心進(jìn)貨質(zhì)量驗收計劃</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術(shù)培訓(xùn)與推廣中心進(jìn)貨質(zhì)量驗收計劃</title>
    ??????????????????????? <dir>doc/2/4.doc</dir>
    ??????????????????? </entity>
    ??????????????????? <entity>
    ??????????????????????? <nick>5</nick>
    ??????????????????????? <description>國家Linux技術(shù)培訓(xùn)與推廣中心培訓(xùn)協(xié)議書</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術(shù)培訓(xùn)與推廣中心培訓(xùn)協(xié)議書</title>
    ??????????????????????? <dir>doc/2/5.doc</dir>
    ??????????????????? </entity>
    ??????????????????? <entity>
    ??????????????????????? <nick>6</nick>
    ??????????????????????? <description>國家Linux技術(shù)培訓(xùn)與推廣中心外購物品驗收報告</description>
    ??????????????????????? <imageBase>images/paper.gif</imageBase>
    ??????????????????????? <imageOpen>images/paper.gif</imageOpen>
    ??????????????????????? <title>國家Linux技術(shù)培訓(xùn)與推廣中心外購物品驗收報告</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>
    ????????錯誤出現(xiàn)在: 1、content.removeContent(_element);
    ??????????2、 //_element.removeContent(_element);

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

    posted on 2006-05-25 18:22 放水老倌 閱讀(397) 評論(0)  編輯  收藏 所屬分類: XML
    主站蜘蛛池模板: 亚洲成人高清在线观看| 国产成人免费a在线视频色戒| 美丽的姑娘免费观看在线播放| 久久精品国产69国产精品亚洲| 国产免费不卡视频| 毛片大全免费观看| 免费一级肉体全黄毛片| 久久久婷婷五月亚洲97号色 | 久久久久久精品免费免费自慰| 性色av极品无码专区亚洲| 亚洲精品国产高清在线观看| 精品在线视频免费| 无码人妻AV免费一区二区三区| 一级毛片免费观看不收费| 蜜桃AV无码免费看永久| 亚洲天堂一区二区三区四区| 永久免费毛片在线播放| 久久精品国产亚洲av麻豆| 男女超爽视频免费播放| 在线观看亚洲精品国产| 亚洲男人天堂影院| 人妻在线日韩免费视频| 大胆亚洲人体视频| 亚洲欧美日韩国产成人| 久久99热精品免费观看牛牛| 亚洲国产成人九九综合| a国产成人免费视频| 亚洲最大视频网站| 免费h成人黄漫画嘿咻破解版| 亚洲国产精品久久久久婷婷软件| 国产亚洲AV夜间福利香蕉149| 亚洲中文无码av永久| 鲁丝片一区二区三区免费 | 99xxoo视频在线永久免费观看| 久久免费视频99| 国产AV无码专区亚洲AV漫画 | 91网站免费观看| 亚洲欧美日韩中文字幕在线一区| 久爱免费观看在线网站| 亚洲熟妇无码一区二区三区 | 18亚洲男同志videos网站|