Esempio n. 1
0
 @Override
 public void endElement(String uri, String localName, String qName) throws SAXException {
   switch (qName) {
       // Add the employee to list once end tag is found
     case "employee":
       empList.add(emp);
       break;
       // For all other end tags the employee has to be updated.
     case "firstName":
       emp.firstName = content;
       break;
     case "lastName":
       emp.lastName = content;
       break;
     case "location":
       emp.location = content;
       break;
   }
 }
Esempio n. 2
0
  @Override
  // Triggered when the start of tag is found.
  public void startElement(String uri, String localName, String qName, Attributes attributes)
      throws SAXException {

    switch (qName) {
        // Create a new Employee object when the start tag is found
      case "employee":
        emp = new Employee();
        emp.id = attributes.getValue("id");
        break;
    }
  }