Java Utililty Methods XML Element Root

List of utility methods to do XML Element Root

Description

The list of methods to do XML Element Root are organized into topic(s).

Method

ElementgetRoot(Document doc)
get Root
Node n = doc.getFirstChild();
while (n != null) {
    if (n instanceof Element) {
        return (Element) n;
    n = n.getNextSibling();
return null;
...
ElementgetRoot(Document doc)
get Root
return doc.getDocumentElement();
ElementgetRoot(Document document)
get Root
return getRoot(document, "root");
ElementgetRoot(final Document doc)
Get root element of the given document.
if (doc != null)
    return doc.getDocumentElement();
return null;
SOAPElementgetRoot(SOAPElement e)
Returns the root element of e
List<SOAPElement> parents = getParents(e);
int size = parents.size();
if (size > 0) {
    return parents.get(size - 1);
} else {
    return e;
ElementgetRootElement(Document d)
If first node found is not an element, returns null.
if (d == null) {
    return null;
NodeList list = d.getChildNodes();
if (list.getLength() <= 0) {
    return null;
} else {
    Node n = list.item(0);
...
ElementgetRootElement(Document doc)
Return the root Element of a Document .
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;
ElementgetRootElement(Document doc)
Return the root element for specified document (null if not found)
return getRootElement(doc, false);
ElementgetRootElement(Document doc)
get Root Element
Node node = doc.getFirstChild();
while (node != null) {
    if (node.getNodeType() == Node.ELEMENT_NODE)
        return (Element) node;
    node = node.getNextSibling();
return null;
ElementgetRootElement(Document document)
get Root Element
if (document != null) {
    return document.getDocumentElement();
return null;