Note that there are some explanatory texts on larger screens.

plurals
  1. POappend node to an xml in Java
    primarykey
    data
    text
    <p>I can't append correctly some info to my xml file. That's the scrivi function</p> <pre><code> public String scrivi (Document doc, File dest) { try { DOMSource sorgente = new DOMSource (doc); StreamResult sr = new StreamResult (dest); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transf = tf.newTransformer(); transf.transform (sorgente, sr); return "Tutto ok"; } catch (TransformerConfigurationException tce) { System.out.println(tce.getMessage()); return "&lt;h1&gt; Config &lt;/h1&gt;"; } catch (TransformerException te) { System.out.println(te.getMessage()); return "&lt;h1&gt; Transformer Errore &lt;/h1&gt;"; } } </code></pre> <p>and tath is my code:</p> <pre><code> try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document document = db.parse(getClass().getResourceAsStream("/azioni.xml")); Element root = document.getDocumentElement(); Element new_azione = document.createElement("azione"); Element id = document.createElement("id_azione"); id.setTextContent(id_azione); Element nome = document.createElement("nome_azione"); nome.setTextContent(nome_azione); Element prezzo_a = document.createElement("prezzo"); prezzo_a.setTextContent(prezzo); new_azione.appendChild(id); new_azione.appendChild(nome); new_azione.appendChild(prezzo_a); document.getDocumentElement().appendChild(new_azione); String nomexmlOut="/azioni.xml"; File filedest = new File(nomexmlOut); out.println(this.scrivi(document, filedest)); } </code></pre> <p>I get the error Transformer Errore ... how can I solve? what's Wrong? <strong>* UPDATE *</strong> Error Info</p> <pre><code>java.io.FileNotFoundException: /azioni.xml (Permission denied) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload