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

     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)); 
      }

 

posted on 2014-11-19 11:28  rojas  阅读(3183)  评论(0编辑  收藏  举报