There is an xml file:
<shop> <department number= "1" name="unknown"> <product id="1"/> <product id="2"/> <product id="3"/> </department> <department number= "2" name="unknown"> <product id="4"/> <product id="5"/> <product id="6"/> </department> <department number= "3" name="unknown"> <.../> </department> </shop> To save information during parsing, I created the Department class and the ArrayList<Department> collection to store these classes there. The class itself looks like this:
class Department { String number; String name; ArrayList<Integer> productId = new ArrayList<>(); // коллекция для хранения аттрибутов product id //конструктор public Department(String n, String na, ArrayList<Integer> pr) { this.number = n; this.name = na; this.productId = pr; } } How can I organize the work of the parser so that in each copy of the Departament class only its child tags product id are placed and placed in a specific ArrayList<Integer> ?