A Method for Inserting a New Entry in a List
public void insertPerson(Document doc, String name,String phone,String email) { Element personNode = doc.createElement("person"); Element nameNode = doc.createElement("name"); personNode.appendChild(nameNode); Text nametextNode = doc.createTextNode(name); nameNode.appendChild(nametextNode); Element phoneNode = doc.createElement("phone"); personNode.appendChild(phoneNode); Text phonetextNode = doc.createTextNode(phone); phoneNode.appendChild(phonetextNode); Element emailNode = doc.createElement("email"); personNode.appendChild(emailNode); Text emailtextNode = doc.createTextNode(email); emailNode.appendChild(emailtextNode); Element root = doc.getDocumentElement(); Node firstChildNode = root.getFirstChild(); root.insertBefore(personNode,firstChildNode); }