import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.SAXException;
import java.io.IOException;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
public class MainClass {
public static void main(String args[]) throws IOException, SAXException {
DOMParser parser = new DOMParser();
parser.parse("games.xml");
Document dom = parser.getDocument();
NodeList games = dom.getElementsByTagName("game");
for (int i = 0; i < games.getLength(); i++) {
Node aNode = games.item(i);
System.out.println(textNode.getFirstChild().getNodeValue());
}
}
}
|