Here you can find the source of getParentElement(Node node)
public static Element getParentElement(Node node)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { /** Gets parent element or null if there is none. */ public static Element getParentElement(Node node) { Node parent = node.getParentNode(); return (parent instanceof Element ? (Element) parent : null); }//from www .ja v a 2s. c o m }