android - Get all data and sub data of a complexe xml in organized way -
i want data in xml associated sub data : example want take name3 in categorie2 , name5 in name3 , name7 in name5 etc...
currently know how name3, name 5 , name7 can't know associated who.
if need more information, ask me.
thank help.
edit
i tried take data :
url3= new string(""); xml3 = parser.getxmlfromurl(url3); document doc3 = parser.getdomelement(xml3); //system.out.println(xml); menubase = new arraylist<hashmap<string, string>>(); nodelist nodes = doc3.getelementsbytagname(key_category_2); (int = 0; < nodes.getlength(); i++) { hashmap<string, string> map = new hashmap<string, string>(); element element = (element) nodes.item(i); nodelist title = element.getelementsbytagname(key_name_3); element line = (element) title.item(0); map.put(key_name_3, getcharacterdatafromelement(line)); menubase.add(map); menu1 = new arraylist<arraylist<hashmap<string, string>>>(); arraylist<hashmap<string, string>> map1 = new arraylist<hashmap<string, string>>(); nodelist n = doc3.getelementsbytagname(key_category_4); (int y = 0; y < n.getlength(); y++) { hashmap<string, string> map1bis = new hashmap<string, string>(); element e = (element) n.item(y); nodelist title1 = e.getelementsbytagname(key_name_5); element line1 = (element) title1.item(0); map1bis.put(key_name_5, getcharacterdatafromelement(line1)); map1.add(map1bis); menu1.add(map1); } }
and tried create menu , sub menu that:
for(int i=0;i<menubase.size();i++){ submenu x=menu.addsubmenu(menubase.get(i).get(key_name_3).tostring()); for(int y=0;y<menu1.get(i).size();y++){ submenu w=x.addsubmenu(menu1.get(i).get(y).get(key_name_5).tostring()); } }
but in each menu item have sub menu item
i got solution of mine probleme :
nodelist nodes = doc3.getelementsbytagname(key_category_2); int sum0=0; for(int i=0;i<menubase.size();i++){ submenu x=menu.addsubmenu(changetoregularform(menubase.get(i).get(key_name_3).tostring())); int count0 = ((element)(nodes.item(i))).getelementsbytagname(key_category_4).getlength(); system.out.println(count0); if(count0==0){ /*x.finditem(i).set*/ }else{ for(int y=sum0;y<sum0+count0;y++){ submenu w=x.addsubmenu(changetoregularform(menu1.get(y).get(key_name_5).tostring())); } } sum0+=count0; }
explanation : take child element in 1 arrylist use fonction count how each element have child element , had them.
if need more information/accuracy, ask for.
Comments
Post a Comment