difference between org.w3c.dom.Document and org.dom4j.Document

3.4k Views Asked by At

why we need this two Document

1) org.w3c.dom.Document 2) org.dom4j.Document

What is difference between this two ?

public static org.dom4j.Document getDom4jDocument(Document w3cDocument)
    {
        //System.out.println("XMLUtility : Inside getDom4jDocument()");
        org.dom4j.Document dom4jDocument  = null;
        DOMReader xmlReader  = null;
        try{
            //System.out.println("Before conversion of w3cdoc to dom4jdoc");
            xmlReader = new DOMReader();            
            dom4jDocument = xmlReader.read(w3cDocument);
            //System.out.println("Conversion complete");
        }catch(Exception e){
            System.out.println("General Exception :- "+e.getMessage());
        }
        //System.out.println("XMLUtility : getDom4jDocument() Finished");
        return dom4jDocument;   
    } 
1

There are 1 best solutions below

2
On BEST ANSWER

org.w3c.dom.Document is standard API on Java SE while org.dom4j.Document is for Dom4J. There are not compatible with each other.

You don't need the 2, it depends on your flavour. Some prefer using Dom4J and some stick to the standard Java SE API.