public static Element getRootElement(Document doc) {
        if (doc == null) return null;
        NodeList children = doc.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node node = children.item(i);
            if (node instanceof Element) return (Element) node;
        }
        return null;
    }
public static Element getRootElement(Document doc) {
        if (doc == null) return null;
        NodeList children = doc.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node node = children.item(i);
            if (node instanceof Element) return (Element) node;
        }
        return null;
    }
public static Element getRootElement ( Document doc ) { if ( doc == null ) return null ; NodeList children = doc . getChildNodes ( ) ; for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { Node node = children . item ( i ) ; if ( node instanceof Element ) return ( Element ) node ; } return null ; }
Return the root {@link Element} of a {@link Document}.

@param doc the document, where the root element is looked up
@return root element of the document or null, if not found
Return the root { @link Element } of a { @link Document } .