Java Utililty Methods XML Node Parent

List of utility methods to do XML Node Parent

Description

The list of methods to do XML Node Parent are organized into topic(s).

Method

ElementgetParent(Element elem)
get Parent
Node parent = elem.getParentNode();
if (parent instanceof Element)
    return (Element) parent;
return null;
NodegetParent(final Node n)
get Parent
return n instanceof Attr ? ((Attr) n).getOwnerElement() : n.getParentNode();
NodegetParent(Node node)
Gets parent node of the given node
return (node.getNodeType() == Node.ATTRIBUTE_NODE) ? ((Attr) node).getOwnerElement() : node.getParentNode();
ElementgetParent(Node target)
get Parent
Node parent = target.getParentNode();
while (parent != null) {
    if (parent.getNodeType() == Node.ELEMENT_NODE)
        return (Element) parent;
    parent = parent.getParentNode();
return null;
ElementgetParentElement(Element element)
Gets the parent element.
if (element == null) {
    return null;
Element parentElement = null;
Node parentNode = element.getParentNode();
while (parentNode != null && parentElement == null) {
    if (parentNode.getNodeType() == Node.ELEMENT_NODE) {
        parentElement = (Element) parentNode;
...
ElementgetParentElement(Element element)
Get parent element of specified element
Node parent = element.getParentNode();
while (parent != null) {
    if (parent instanceof Element)
        return (Element) parent;
    parent = parent.getParentNode();
return null;
ElementgetParentElement(final Node node)
get Parent Element
final Node parent = node.getParentNode();
return parent instanceof Element ? (Element) parent : null;
ElementgetParentElement(Node node)
Gets parent element or null if there is none.
Node parent = node.getParentNode();
return (parent instanceof Element ? (Element) parent : null);
ElementgetParentElement(Node node)
get Parent Element
Node parent = node.getParentNode();
if (parent == null || parent.getNodeType() != Node.ELEMENT_NODE) {
    return null;
} else {
    return (Element) parent;
ElementgetParentElement(Node node)
Gets parent element or null if there is none
Node parent = node.getParentNode();
return (parent instanceof Element ? (Element) parent : null);