Here you can find the source of getChildNodesByName(Node element, String name, boolean caseSensitive)
Parameter | Description |
---|---|
element | Element |
name | String |
caseSensitive | boolean |
public static List<Node> getChildNodesByName(Node element, String name, boolean caseSensitive)
//package com.java2s; //License from project: LGPL import org.w3c.dom.*; import java.util.ArrayList; import java.util.List; public class Main { /**//from w w w . ja va 2s . c o m * Helper Method. Searches through the child nodes of an element and returns an array of the matching nodes. * @param element Element * @param name String * @param caseSensitive boolean * @return ArrayList */ public static List<Node> getChildNodesByName(Node element, String name, boolean caseSensitive) { ArrayList<Node> nodes = new ArrayList<Node>(); NodeList list = element.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); if (caseSensitive) { if (node.getNodeName().equals(name)) nodes.add(node); } else { if (node.getNodeName().equalsIgnoreCase(name)) nodes.add(node); } } return nodes; } }