Here you can find the source of getChild(Element root, String... path)
static Element getChild(Element root, String... path)
//package com.java2s; //License from project: Open Source License import java.util.Objects; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { static Element getChild(Element root, String... path) { if (root == null || path.length == 0) return null; Element element = root;//w ww . j a v a2 s .c om for (String tagName : path) { if (element == null) return null; NodeList list = element.getChildNodes(); if (list == null || list.getLength() == 0) return null; element = null; for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); if (!(node instanceof Element)) continue; Element child = (Element) node; if (Objects.equals(child.getLocalName(), tagName)) { element = child; break; } } } return element; } }