Java tutorial
import java.io.FileReader; import java.util.HashMap; import java.util.Map; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamReader; public class Main { public static void main(String[] args) throws Exception { XMLInputFactory xif = XMLInputFactory.newFactory(); XMLStreamReader xsr = xif.createXMLStreamReader(new FileReader("data.xml")); xsr.nextTag(); // advance to Employees tag xsr.nextTag(); // advance to first Employer element Map<String, String> map = new HashMap<String, String>(); while (xsr.getLocalName().equals("Employee")) { map.put(xsr.getAttributeValue("", "id"), xsr.getElementText()); xsr.nextTag(); // advance to next Employer element } } }