I am consuming an XML file using the Java API for XML (JAXP), and I have a sequence of Nodes that will be inside a 'container' node. There will only ever be exactly one container node. Here is a simplistic example:
In this example, the <Employees> tag is nothing more than a container for the list of <Employee> nodes. There will always be exactly one <Employees> node. Right now I am reading this in as follows:
Node employees = doc.getElementsByTagName("Employees").item(0);
Element employeeElement = (Element) employees;
NodeList empList = employeeElement.getElementsByTagName("Employee");
This works, but I have a suspicion that this is not the best way to get the list of employee nodes. Certainly not the most elegant. Is there a better way to do this?