001package armyc2.c2sd.renderer.utilities; 002 003import org.w3c.dom.Document; 004import org.w3c.dom.Element; 005import org.w3c.dom.Node; 006import org.w3c.dom.NodeList; 007 008/** 009 * 010 * @author michael.spinelli 011 */ 012public class XMLUtil 013{ 014 015 /** 016 * This method returns the list of objects in a list form. 017 * 018 * @param document the document to pull the list from 019 * @param tag the name of the element 020 * @return the list of items 021 */ 022 public static NodeList getItemList(Document document, String tag) 023 { 024 return document.getElementsByTagName(tag); 025 } 026 027 /** 028 * This method parse the xml tag value. 029 * 030 * @param node the node to pull an element from 031 * @param tag the name of the element 032 * @return the text content of the element 033 */ 034 public static String parseTagValue(Node node, String tag) 035 { 036 if (node.getNodeType() == Node.ELEMENT_NODE) { 037 Element element = (Element) node; 038 return element.getElementsByTagName(tag).item(0).getTextContent(); 039 } 040 return null; 041 } 042}