Io ho un file xml già creato. Come faccio per aggiungere un nodo al suo interno?
Io ho provato a fare così:
Ma devo poi salvare il file con PrintStream?codice:DocumentBuilderFactory docfactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = docfactory.newDocumentBuilder(); Document d = builder.parse(application.getRealPath("/") + "rubrica.xml"); radice = d.getDocumentElement(); Element persona = d.createElement("persona"); Element nome = d.createElement("nome"); nome.appendChild(d.createTextNode(n)); persona.appendChild(nome); radice.appendChild(persona);
Potete darmi qualche indicazione? grazie

Rispondi quotando