Java XML Element Root getRoot(Document doc)

Here you can find the source of getRoot(Document doc)

Description

get Root

License

Open Source License

Declaration

public static final Element getRoot(Document doc) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class Main {
    public static final Element getRoot(Document doc) {
        Node n = doc.getFirstChild();
        while (n != null) {
            if (n instanceof Element) {
                return (Element) n;
            }//  w ww  .  j  a v a 2 s  .co  m
            n = n.getNextSibling();
        }
        return null;
    }
}

Related

  1. getElementData(final Element root, final String elementName)
  2. getElementData(final Element root, final String elementName)
  3. getElementText(String elemName, Element root, boolean trim)
  4. getElementValue(Element root, String name)
  5. getElementValueLong(Element root, String name)
  6. getRoot(Document doc)
  7. getRoot(Document document)
  8. getRoot(final Document doc)
  9. getRoot(SOAPElement e)