org.w3c.dom.Document 与org.dom4j.Document互转

时间:2014-11-19 12:32:03   收藏:0   阅读:256
     public   static   Document   parse(org.w3c.dom.Document   doc)   throws   Exception   { 
          if   (doc   ==   null)   { 
              return   (null); 
          } 
          org.dom4j.io.DOMReader   xmlReader   =   new   org.dom4j.io.DOMReader(); 
          return   (xmlReader.read(doc)); 
      } 
  
       
      public   static   org.w3c.dom.Document   parse(Document   doc)   throws   Exception   { 
          if   (doc   ==   null)   { 
              return   (null); 
          } 
          java.io.StringReader   reader   =   new   java.io.StringReader(doc.asXML()); 
          org.xml.sax.InputSource   source   =   new   org.xml.sax.InputSource(reader); 
          javax.xml.parsers.DocumentBuilderFactory   documentBuilderFactory   = 
                  javax.xml.parsers.DocumentBuilderFactory.newInstance(); 
          javax.xml.parsers.DocumentBuilder   documentBuilder   =   documentBuilderFactory. 
                  newDocumentBuilder(); 
          return   (documentBuilder.parse(source)); 
      }

 

原文:http://www.cnblogs.com/rojas/p/4107828.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!