Deleting a child node

Capyerevy

New Member
Here is a screen shot of my existing XML, I would like to delete a certain animation state. Here is how it looks,
3qU1I.png
Now if a user does not want run, I should have
uF3OD.png
As you can see, I would like to delete the entire animation_state, along with it's children,state, animation sequence, etc.Here is my attempt, please help me! I've spent hours trying to delete it.\[code\]DOMParser parser = new DOMParser(); String path ="./data/sprite_types/"+Poseur.getPoseur().getGUI().spriteViewer.getSpriteTypeList().getSelectedValue()+"/" +Poseur.getPoseur().getGUI().spriteViewer.getSpriteTypeList().getSelectedValue()+".xml"; try { parser.parse(path); } catch (SAXException ex) { Logger.getLogger(RenameStateHandler.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(RenameStateHandler.class.getName()).log(Level.SEVERE, null, ex); } Document dom = parser.getDocument(); for(int i = 0; i<dom.getElementsByTagName("animation_state").getLength(); i++) { if(dom.getElementsByTagName("animation_state").item(i).getChildNodes().item(0).getTextContent(). equalsIgnoreCase(target)) { posVal = i; Node temp = dom.getElementsByTagName("animation_state").item(i); dom.getElementsByTagName("animations_list").item(i). removeChild(temp); } }\[/code\]
 
Back
Top