ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>();
XMLParser parser = new XMLParser();
String xml = parser.getXmlFromUrl(url); // getting XML
int displayPerPage = 5;
int TotalRows = xml.length();
Document doc = parser.getDomElement(xml); // getting DOM element
NodeList nl = doc.getElementsByTagName(KEY_ITEM);
// looping through all item nodes <item>
for (int i = 0; i < nl.getLength(); i++) {
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
Element e = (Element) nl.item(i);
// adding each child node to HashMap key => value
map.put(KEY_NAME, parser.getValue(e, KEY_NAME));
// adding HashList to ArrayList
menuItems.add(map);
}
This is my Code i want to Count nUmber of node i m not able to do this please tell me how i will do it http://api.androidhive.info/pizza/?format=xml suppose this my xml contaion 10 item or Node how i will count please post me code for that
Just use
nl.getLength(), it’ll return you the number of items in each tag.