[ https://issues.apache.org/jira/browse/XERCESJ-911?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14365609#comment-14365609 ]
Michael Glavassevich commented on XERCESJ-911: ---------------------------------------------- Here's a pointer to a rather long discussion on this subject on the j-users mailing list in 2011: http://markmail.org/thread/mivj2rtk2gs6d6so. Very unlikely that the design is going to change at this point. > Traversing the DOM throws NullPointerException > ---------------------------------------------- > > Key: XERCESJ-911 > URL: https://issues.apache.org/jira/browse/XERCESJ-911 > Project: Xerces2-J > Issue Type: Bug > Components: DOM (Level 3 Core) > Affects Versions: 2.6.2 > Environment: Operating System: Other > Platform: PC > Reporter: Malik Hemani > > 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. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: j-dev-unsubscr...@xerces.apache.org For additional commands, e-mail: j-dev-h...@xerces.apache.org