How to parse same name tag in Android XML DOM Parsing?

Your getValue() method gets MyResource element, from there, you need to get all Items under MyResource and do getElementValue(). Example code is:

   public Map getValue(Element item, String str) {
        NodeList n = item.getElementsByTagName(str);
        for (int i = 0; i < n.getLength(); i++) {
            System.out.println(getElementValue(n.item(i)));
        }
        //Here store it in list/map and return list/map instead of String
        return list/MapHere;
    }

Leave a Comment