Java examples for XML:DOM Node
Get List of Children XML Node With Name
//package com.java2s; import java.util.ArrayList; import java.util.List; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { static public List<Node> GetListofChildrenWithName(Node targetNode, String targetString) { List<Node> retNodeList = new ArrayList<Node>(); NodeList ChildNodeList = targetNode.getChildNodes(); for (int i = 0; i < ChildNodeList.getLength(); i++) { if (ChildNodeList.item(i).getNodeName().equals(targetString)) { retNodeList.add(ChildNodeList.item(i)); }//ww w . j ava 2 s . c om } return retNodeList; } }