DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27454>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27454 Traversing the DOM throws NullPointerException Summary: Traversing the DOM throws NullPointerException Product: Xerces2-J Version: 2.6.2 Platform: PC OS/Version: Other Status: NEW Severity: Major Priority: Other Component: DOM AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] I'm traversing a Document parsed by the DOMParser and running into NullPointerExceptions. The exception occurs at org.apache.xerces.dom.ParentNode.nodeListItem(Unknown Source) org.apache.xerces.dom.ParentNode.item(Unknown Source) Sometimes is it also seen when 'NodeList.getLength()' is called. The traversing is done using a for loop and recursing into the routine, EXAMPLE: ======== Node findNode(Node parentNode) { NodeList childNodes = parentNode.getChildNodes(); for(int i = 0; i < childNodes.getLength(); i++) { Node child = childNodes.item(i); if (child != null && child.getNodeType != Node.ELEMENT_NODE) { continue; } else { // do something ... ... } } // Then recursively call the above routine for (int i = 0; i < childNodes.getLength(); i++) { Node child = childnodes.item(i); if (child != null) { Node found = findNode(child); // more code to follow ... ... } } } If you need the sample XML document, I prefer to email it you. Thanks. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
