title: Getting parent information from child node in XML
body: <p>I currently have some xml along the lines of:</p>
  
  <pre><code>&lt;Schools&gt;
      &lt;School SchoolName="name1" ... &gt;
          &lt;Students&gt; 
              &lt;Student studentName="student1" .../&gt;
              &lt;Student studentName="student2" .../&gt;
          &lt;/Stuidents&gt;
      &lt;/School&gt;
      &lt;School SchoolName="name2" ...&gt;
          &lt;Students&gt;
              &lt;Student studentName="student3" ... /&gt;
              &lt;Student studentName="student3" ... /&gt;
          &lt;/Students&gt;
      &lt;/School&gt;
  &lt;/Schools&gt;
  </code></pre>
  
  <p>If I make a node list of "School" and "Student" using a DOM parser, within the Student node list how am I able to get SchoolName from the student so that I am able to save in a Database/Student Class : StudentName, Student Details, SchoolName.</p>
  
  <pre><code>NodeList schoolNodeList = docEle.getElementsByTagName("School");
  NodeList studentNodeList = docEle.getElementsByTagName("Student");
  
  parseStudentNodeList(studentNodeList);
  
  private void parseStudentNodeList(NodeList studentsNodeList)
  {
      Student student = new Student();
      for (int i = 0; i &lt; studentNodeList.getLength(); i++)
      {
          Element el (Element) studentNodeList.item(i);
          student.setName(el.getAttribute("studentName"));
          student.setSchool( /* Help needed here */ );
      }
  }
  </code></pre>
  
  <p>Preferably by not adding a "SchoolName" variable into the Student section.</p>