Here is a screen shot of my existing XML, I would like to duplicate a certain animation state. Here is how it looks,
Now if a user wished to duplicate the run state, I should have the same children, just strictly the state name should be changed. Below are screen shots and my attempt
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.String userInput = JOptionPane.showInputDialog( null, "Before we duplicate the state, which name would you like to give it?", JOptionPane.QUESTION_MESSAGE);\[code\] int posVal; String target = Poseur.getPoseur().getGUI().spriteViewer.getSpriteStateComboBox().getSelectedItem().toString(); 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); temp.getChildNodes().item(0).setTextContent(userInput); temp.getParentNode().appendChild(temp); } }\[/code\]