Here you can find the source of getChildElements(Node node)
public static List<Element> getChildElements(Node node)
//package com.java2s; /*// w w w . j a va 2s . com * Copyright 2017 The Portico Project * * This file is part of portico. * * portico is free software; you can redistribute it and/or modify * it under the terms of the Common Developer and Distribution License (CDDL) * as published by Sun Microsystems. For more information see the LICENSE file. * * Use of this software is strictly AT YOUR OWN RISK!!! * If something bad happens you do not have permission to come crying to me. * (that goes for your lawyer as well) * */ import java.util.ArrayList; import java.util.List; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * Return a list of child element types of the provided node. If the node has no children * or none of the children are element nodes, an empty list is returned. */ public static List<Element> getChildElements(Node node) { NodeList list = node.getChildNodes(); ArrayList<Element> elements = new ArrayList<Element>(); for (int i = 0; i < list.getLength(); i++) { Node temp = list.item(i); if (temp.getNodeType() == Node.ELEMENT_NODE) elements.add((Element) temp); } return elements; } }