Ciao ragazzi!
Xerces, questo sconosciuto...
Dovrei modificare un file xml già esistente.
Queste fantastiche righe che vedete qui sotto si occupano della creazione di elementi:
Il listato qui sopra è molto bello e fa (quasi) quello che voglio ottenere io.codice:Document doc= new DocumentImpl(); Element root = doc.createElement("accessi"); // Create Root Element Element item = doc.createElement("accesso"); // Create element item.appendChild( doc.createTextNode("Jeff") ); root.appendChild( item ); // atach element to Root element item = doc.createElement("age"); // Create another Element item.appendChild( doc.createTextNode("28" ) ); root.appendChild( item ); // Attach Element to previous element down tree item = doc.createElement("height"); item.appendChild( doc.createTextNode("1.80" ) ); root.appendChild( item ); // Attach another Element - grandaugther doc.appendChild( root ); OutputFormat format = new OutputFormat( doc ); //Serialize DOM StringWriter stringOut = new StringWriter(); //Writer will be a String XMLSerializer serial = new XMLSerializer( stringOut, format ); serial.asDOMSerializer(); // As a DOM Serializer serial.serialize( doc.getDocumentElement() ); // System.out.println("prova" + stringOut.toString()); // questa istruzione mostra l'xml String AggiuntaXml = stringOut.toString();
Ma come faccio a modificare un xml già esistente?
Lo so..mi sto perdendo in un bicchiere d'acqua..![]()
Qualcuno mi sa aiutare?
Grazie