import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
publicclass Utils {
/**
* Return a list of named Elements.
* @param element the containing Element
* @param name the tag name
* @return NodeList of matching elements
*/
publicstatic NodeList getElementList(Element element, String name) {
return element.getElementsByTagName(name);
}
/**
* Return the first named Element found. Null if none.
* @param element the containing Element
* @param name the tag name
* @return matching Element (null if none)
*/
publicstatic Element getElement(Element element, String name) {
NodeList nodeList = getElementList(element, name);
return (nodeList.getLength() == 0) ? null : (Element) nodeList.item(0);
}
}