Rising Sun

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            148 隨筆 :: 0 文章 :: 22 評論 :: 0 Trackbacks
          <2008年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(10)

          隨筆分類

          隨筆檔案

          相冊

          java--->ajax

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          利用w3c的dom:

           

          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 
            DocumentBuilder builder;
            
          try   {
             builder 
          =  factory.newDocumentBuilder();
             Document doc 
          =  builder.parse( new  ByteArrayInputStream(str.getBytes())); 
            }
            catch  (ParserConfigurationException e)  {
             
          //  TODO Auto-generated catch block
             e.printStackTrace();
            }
            catch  (SAXException e)  {
             
          //  TODO Auto-generated catch block
             e.printStackTrace();
            }
            catch  (IOException e)  {
             
          //  TODO Auto-generated catch block
             e.printStackTrace();
            }
           


          利用1 dom4j

          SAXReader saxReader = new SAXReader();
                  Document document;
                  
          try {
                      document 
          = saxReader.read(new ByteArrayInputStream(str.getBytes()));
                      Element incomingForm 
          = document.getRootElement();
                  }
           catch (DocumentException e) {
                      
          // TODO Auto-generated catch block
                      e.printStackTrace();
                  }


          利用 2 dom4j :


          String text = "<person> <name>James</name> </person>";
          Document document = DocumentHelper.parseText(text);
          posted on 2008-07-29 11:17 brock 閱讀(175) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 平潭县| 颍上县| 丽水市| 翁牛特旗| 江津市| 镇雄县| 同仁县| 茌平县| 藁城市| 开江县| 桦川县| 随州市| 大新县| 新宾| 綦江县| 鹤山市| 措勤县| 波密县| 米易县| 罗江县| 永丰县| 上杭县| 高阳县| 辽中县| 霍城县| 宜川县| 松潘县| 文登市| 满洲里市| 北碚区| 宝山区| 岳阳县| 龙井市| 治多县| 枞阳县| 石首市| 酒泉市| 博野县| 五常市| 孟津县| 五河县|