KB-20071226-039
From Triled Wiki
- Status: opened
- author: elDoudou
- link: http://groups.google.com/group/android-developers/msg/33ea68976660b2c2
- Description: Node.getNextSibling() implementation raises java.lang.IndexOutOfBoundsException.
- Steps to reproduce:
code example (from original post):
01: Node child = elt.getFirstChild();
02: while (child != null) {
03: if (child.getNodeType() == Node.ELEMENT_NODE &&
04: child.getNodeName().equals(nodeName))
05: {
06: return (Element) child;
07: }
08: child = child.getNextSibling();
09: }
Exception is raised at 8th line.
However, following code works fine:
NodeList childNodes = elt.getChildNodes();
for (int index = 0; index < childNodes.getLength(); index++) {
Node child = childNodes.item(index);
if (child.getNodeType() == Node.ELEMENT_NODE &&
child.getNodeName().equals(nodeName))
{
result.add((Element) child);
}
}
