Good afternoon, ladies and gentlemen! I ran into this question. There is an XML file like this:
And there is a method code that adds the values to the Employee entity:
@Override public void characters(char[] ch, int start, int length){ if(thisElement.equals("Employee")){ em = new Employee(); } if(thisElement.equals("age")){ em.setAge(new Integer(new String(ch, start, length))); System.out.println(em.getAge()); } if(thisElement.equals("name")){ em.setName(new String(ch, start, length)); System.out.println(em.getName()); } if(thisElement.equals("gender")){ em.setGender(new String(ch, start, length)); System.out.println(em.getGender()); } if(thisElement.equals("role")){ em.setRole(new String(ch, start, length)); System.out.println(em.getRole()); list.add(em); em = null; } } The output is this result:
Employee {id: 0, age: 29, name: Pankaj, gender: Male, role: Java Developer} Employee {id: 0, age: 35, name: Lisa, gender: Female, role: CEO}
And now the question: Can you please tell me how much I want to go to id in Employee?