Here you can find the source of getParentElement(final Node node)
public static Element getParentElement(final Node node)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static Element getParentElement(final Node node) { final Node parent = node.getParentNode(); return parent instanceof Element ? (Element) parent : null; }/*from www .j a va2 s . c o m*/ }