Java tutorial
//package com.java2s; //License from project: Apache License import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { public static NodeList findNodes(Document document, String nodeName) { if (document == null) throw new NullPointerException("Document cannot be null!"); if (nodeName == null) throw new NullPointerException("Nodename cannot be null!"); return document.getElementsByTagName(nodeName); } public static NodeList findNodes(Element parentNode, String nodeName) { if (parentNode == null) throw new NullPointerException("Parent Node cannot be null!"); if (nodeName == null) throw new NullPointerException("Nodename cannot be null!"); return parentNode.getElementsByTagName(nodeName); } }