I have been using this code to parse xml till now. Its was working fine in previous version of android(till 2.3.3).
NodeList list = element.getElementsByTagName("course");
Element entry;
Element title;
if(list != null && list.getLength() > 0){
for(int i=0;i < list.getLength(); i++){
entry = (Element)list.item(i);
title = (Element)entry.getElementsByTagName("course").item(0);
biz_name_p = title.getAttribute("biz_name");
}
}
I have Multiple tags with name “course” so i am taking it in a List. Inside loop im checking for elements course and extracting several string values from it.
It throws NullPointerException when i try to getAttribute("biz_name") or any other attributes.
This was working fine in previous version until ICS…
When i Replace “course” with primary tag in the list(which only repeats once in whole xml),
i am receiving the string value but only once… Did they change any thing in Dom parser ??
EDIT
following is the xml im trying to parse..
<golf>
<course biz_name="Club Circle Golf Course"/>
<course biz_name="Club Circle Golf Course1"/>
<course biz_name="Club Circle Golf Course2"/>
</golf>
I don’t understand why
getElementsByTagNameis called multiple times. So can you try this: