Java tutorial
//package com.java2s; //License from project: Apache License import java.io.FileInputStream; import java.util.Vector; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static Vector<String> getHandsets(String file) throws Exception { Vector<String> vec = new Vector(); DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance(); DocumentBuilder dombuilder = domfac.newDocumentBuilder(); FileInputStream is = new FileInputStream(file); Document doc = dombuilder.parse(is); NodeList nodeList = doc.getElementsByTagName("devices"); if (nodeList != null && nodeList.getLength() >= 1) { Node deviceNode = nodeList.item(0); NodeList children = deviceNode.getChildNodes(); if (children != null && children.getLength() >= 1) { for (int i = 0; i < children.getLength(); i++) { vec.add(children.item(i).getTextContent()); } } } return vec; } }