1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
public void supprimer(String machine){
//lecture du fichier
SAXBuilder sxb = new SAXBuilder();
try{
document=sxb.build(new File("personne.xml"));
personne=document.getRootElement();
}catch(Exception e){}
List listClient = reseau.getChildren("etudiant");
Iterator i = listClient.iterator();
while(i.hasNext()){
Element courant = (Element)i.next();
if(courant.getChild("nom").getValue().equals("Cyn")){
courant.removeChild("nom");
courant.removeChild("prenom");
}
}
try{
XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
sortie.output(document, new FileOutputStream("machine.xml"));
}catch (IOException e){}
} |
Partager