dom4j解析 字符串傳喚成xml

          d
          oc = DocumentHelper.parseText(xml); // 將字符串轉為XML

          map.put(
          "title", title);
                          
                          Iterator
          <?> iters = recordEle.elementIterator("script");

          String title 
          = recordEle.elementTextTrim("title"); // 拿到head節點下的子節點title值
          Iterator iters = map.keySet().iterator();
                  
          while (iters.hasNext()) {
                      String key 
          = iters.next().toString(); // 拿到鍵
                      String val = map.get(key).toString(); // 拿到值
                      System.out.println(key + "=" + val);



          List list = (document.selectNodes("/books/book/@show" )); // xpath解析
                      Iterator iter = list.iterator();
                      while(iter.hasNext()){
                          Attribute attribute = (Attribute)iter.next();
                          if(attribute.getValue().equals("yes")){
                          attribute.setValue("no");
                          }
                         
                          Element ownerElement = (Element)iter.next();
                          Element dateElement = ownerElement.addElement("date");
                          dateElement.setText("2004-09-11");

                      }

           

          posted on 2012-06-14 14:44 youngturk 閱讀(540) 評論(0)  編輯  收藏 所屬分類: 幾種文檔解析

          <2012年6月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          1234567

          導航

          統計

          公告

          this year :
          1 jQuery
          2 freemarker
          3 框架結構
          4 口語英語

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          EJB學習

          Flex學習

          learn English

          oracle

          spring MVC web service

          SQL

          Struts

          生活保健

          解析文件

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 长子县| 石景山区| 榆中县| 交口县| 四平市| 环江| 霍山县| 汨罗市| 高尔夫| 钦州市| 镇坪县| 司法| 本溪市| 昌图县| 浑源县| 页游| 通渭县| 邛崃市| 三门峡市| 乐清市| 彩票| 左贡县| 郑州市| 林甸县| 沙雅县| 武冈市| 三河市| 年辖:市辖区| 浪卡子县| 高州市| 唐山市| 开化县| 邵阳市| 阿瓦提县| 漠河县| 古田县| 宁陵县| 封开县| 赤壁市| 茶陵县| 芦溪县|