How to delete and edit data from an XML file by use of JSP

I want to know how to delete and edit data from an XML file by use of JSP. I have XML file having tasks(root node),task id,project,date(as child nodes). I have many tasks stored in the xml file,I want to delete and edit some tasks using task id then how can i do it in JSP.Please help with example if any.Thank you XML file : tasks.XML::

 <?xml version = '1.0' encoding = 'UTF-8'?>
       <Date>21 February</Date>
       <Date>2 march</Date>
       <Project>Assinment JSP</Project>
       <Date>23 march</Date>
       <Date>7 april</Date>
       <Date>7 april</Date>

I have a java program to remove element but i want to know how to remove by providing element attribute (like task id) and deleting all data IN JSP? I want it in jsp

import org.w3c.dom.*;
import org.xml.sax.*;
import javax.xml.parsers.*;
import javax.xml.transform.*; 
import javax.xml.transform.dom.DOMSource; 

public class RemoveElement {
  static public void main(String[] arg) {
      BufferedReader bf = new BufferedReader(new InputStreamReader(;
      System.out.print("Enter a XML file name: ");
      String xmlFile = bf.readLine();
      File file = new File(xmlFile);
      System.out.print("Enter an element which have to delete: ");
      String remElement = bf.readLine();
      if (file.exists()){
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document doc = builder.parse(xmlFile);
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer tFormer = tFactory.newTransformer();
        Element element = (Element)doc.getElementsByTagName(remElement).item(0);
//        Remove the node
//              Normalize the DOM tree to combine all adjacent nodes
        Source source = new DOMSource(doc);
        Result dest = new StreamResult(System.out);
        tFormer.transform(source, dest);
        System.out.println("File not found!");
    catch (Exception e){