Rising Sun

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            148 隨筆 :: 0 文章 :: 22 評(píng)論 :: 0 Trackbacks

          利用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 閱讀(174) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 黄陵县| 通城县| 腾冲县| 洛隆县| 南川市| 福泉市| 寿阳县| 呈贡县| 九江县| 黑山县| 安徽省| 昌平区| 兖州市| 大足县| 阜城县| 贺兰县| 吉隆县| 措勤县| 青神县| 商丘市| 贵溪市| 武川县| 西城区| 信宜市| 邛崃市| 达孜县| 星子县| 兰西县| 甘谷县| 河曲县| 拉孜县| 大城县| 怀化市| 曲阳县| 南雄市| 喀喇沁旗| 绥宁县| 郯城县| 察雅县| 福安市| 理塘县|