Last child of XML throws NullPointerException

adomin

New Member
Here is my problem, this code below can delete all children from a node, however, when there is one last child remaining, it throws a nullpointer.In particular, I am focused on deleting the pose, if I have 10 of them, I can delete 9, but the last one, will throw nullpointer.The screen shot of a
9op8j.png
JsS4b.png
Here is my code:\[code\] for(int j = 0; j<dom.getElementsByTagName("animation_sequence").getLength(); j++) { NamedNodeMap attributes = dom.getElementsByTagName("pose").item(j).getAttributes(); for (int a = 0; a < attributes.getLength(); a++) { Node theAttribute = attributes.item(a); if(PoseSelectionListener.imageIDOfSelectedPose.equalsIgnoreCase( attributes.item(a).getNodeValue().toString())) { if(removed==false) { Node temp = dom.getElementsByTagName("pose").item(j); removed=true; try{ temp.getParentNode().removeChild(temp); } catch(NullPointerException ex) {return;} } }\[/code\]
 
Back
Top