Here you can find the source of extractNodeListFromElement(Element config, String tag, boolean required)
public static NodeList extractNodeListFromElement(Element config, String tag, boolean required)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { public static NodeList extractNodeListFromElement(Element config, String tag, boolean required) { NodeList node = config.getElementsByTagName(tag); return check1Most(node, tag, required); }/*from ww w.j a v a 2s . com*/ public static NodeList check1Most(NodeList node, String tag, boolean required) { if (node.getLength() == 0) { if (!required) { return null; } throw new RuntimeException("Tag " + tag + " is required in configuration file"); } else if (node.getLength() > 1) { throw new RuntimeException("Only one tag " + tag + " is required in configuration file"); } return node.item(0).getChildNodes(); } }