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

      }

 

你可能感兴趣的:(document)