public Model parse(String filepath) throws ParserConfigurationException, SAXException, IOException { Model pm = new Model(); // Get the DOM Builder Factory DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); // Get the DOM Builder DocumentBuilder builder = factory.newDocumentBuilder(); InputStream in = new FileInputStream(filepath); Document document = builder.parse(in); NodeList transitionList = document.getDocumentElement().getElementsByTagName("transition"); for (int i = 0; i < transitionList.getLength(); i++) { Node transition = transitionList.item(i); String id = transition.getAttributes().getNamedItem("id").getNodeValue(); // System.out.println("ID: " + id); NodeList l1 = transition.getChildNodes(); // System.out.println(l1.getLength()); for (int j = 0; j < l1.getLength(); j++) { if (l1.item(j).getNodeName().equals("name")) { NodeList l2 = l1.item(j).getChildNodes(); for (int k = 0; k < l2.getLength(); k++) { if (l2.item(k).getNodeName().equals("text")) { String label = l2.item(k).getTextContent(); // System.out.println("Label: " + l2.item(k).getTextContent()); if (!(label.matches("^t\\d*"))) { Activity activity = new Activity(id, label); pm.addActivity(activity); } } } } } } return pm; }