Get parent
import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static Element getParent(Element elem) { Node parent = elem.getParentNode(); if (parent instanceof Element) return (Element)parent; return null; } // getParent(Element):Element }