Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

private void parseDocument(){ //get the root elememt Element docEle =dom.getDocu

ID: 3618215 • Letter: P

Question

      private void parseDocument(){
      //get the root elememt
      Element docEle =dom.getDocumentElement();
     
      //get a nodelist of <employee>elements
      NodeList nl =docEle.getElementsByTagName("Employee");
      if(nl != null &&nl.getLength() > 0) {
         for(int i = 0 ; i< nl.getLength();i++) {
           
           //get the employee element
           Element el = (Element)nl.item(i);
           
           //getthe Employee object
           Employee e =getEmployee(el);      //Error 1

//add it to list

            myEmpls.add(e);
         }
      }
   }

/* I take an employee element and read the values in, create anEmployee object and return it
* @param empEl
* @return  

*/
  

private Employee getEmployee(ElementempEl) {       // Error2
     
      //for each <employee> elementget text or int values of name ,id, age
     

String name = getTextValue(empEl,"Name");

int id = getIntValue(empEl,"Id");
int age = getIntValue(empEl,"Age");

String type = empEl.getAttribute("type");
    
      //Create a new Employee with thevalue read from the xml nodes
      Employee e= newEmployee(name,id,age,type);                 //Error 3 & 4                 

      return e;
   }

Explanation / Answer

Compile the Employee class first, andmake sure that it is in the same folder.