I have a 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 the data parsing, I created a class Department
and a collection ArrayList <Department>
, to keep these classes there. The class looks like this:
class Department { String number; String name; ArrayList<Integer> productId = new ArrayList<>(); // collection for storage "attribut id of product" //constructor public Department(String n, String na, ArrayList<Integer> pr) { this.number = n; this.name = na; this.productId = pr; } }
How do I set the SAX-parser to work in each instance of the class Departament
got only his daughter tags product id
and placed in a particular ArrayList <Integer>
?
No comments:
Post a Comment