title: Unable to edit SVG using Batik in Java?
body: <p>I have a student card SVG that has name, id and other field that I want to edit through Java, as the user inputs them using GUI.   </p>
  
  <p>I have successfully parsed the SVG using Batik but I can't see the changes that I made in SVG file when I open it.</p>
  
  <pre><code>String parser = XMLResourceDescriptor.getXMLParserClassName();
  SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
  String uri = "card.svg";
  try {
      Document doc = f.createDocument(uri);
      NodeList nodeList = doc.getChildNodes();
      Element svg = doc.getElementById("name");
      svg.setTextContent("Your Name");
      System.out.println(svg.getTextContent());
  } catch (IOException e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>When I print out one the of SVG element's value using </p>
  
  <p><code>System.out.println(svg.getTextContent());</code> </p>
  
  <p>It's changed but when I open the SVG in notepad it's the same.</p>
  
  <p><strong>SVG</strong></p>
  
  <pre><code>&lt;text x="759" y="361" id="name" class="fil3 fnt3"&gt;STUDENT&lt;/text&gt;
  </code></pre>
  
  <p><strong>UPDATE FOR OTHERS: Solved with</strong> </p>
  
  <pre><code>File file = new File("new.svg");
  FileWriter fWriter = new FileWriter(file);
  XmlWriter.writeXml(svg, fWriter, false);
  // Most crucial part, It wasn't working just because of flush
  fWriter.close();
  </code></pre>