KB-20071226-039

From Triled Wiki

Jump to: navigation, search

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);
        }
    }
Personal tools