It seems like the first element of a NodeList begins at 0 for API<8
but start at 1 for API 8.

When using API<8 I used this code:
...
Document doc = db.parse(urlConn.getInputStream());
NodeList xml = doc.getChildNodes();
// if we have at least 1 result
if (xml.item(1).getChildNodes().item(1) != null) {
    NodeList places = xml.item(1).getChildNodes();
    ...
}

But using API 8, xml.item(1) returns null, the first element is at
xml.item(0), and I think it's quite ugly to do this (even if it then
works in all APIs):

if ((xml.item(0).getChildNodes().item(1) != null) ||
(xml.item(1).getChildNodes().item(1) != null)) {
    NodeList places = xml.item(0).getChildNodes();
    if(places.getLength()==0)
        places = xml.item(1).getChildNodes();
    ...
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to