Here you can find the source of addDescendants(Node node, List
Parameter | Description |
---|---|
node | Node. |
descendants | List of descendants. |
public static void addDescendants(Node node, List<Node> descendants)
//package com.java2s; /* Please see the license information at the end of this file. */ import java.util.*; import org.w3c.dom.*; public class Main { /** Adds descendant elements of a node to a list. *//from w ww. j a v a2 s . c o m * @param node Node. * * @param descendants List of descendants. */ public static void addDescendants(Node node, List<Node> descendants) { NodeList children = node.getChildNodes(); int numChildren = children.getLength(); for (int i = 0; i < numChildren; i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { descendants.add(child); addDescendants(child, descendants); } } } }