title: Refreshing XML file while application is running with DOM, Java
body: <p>i'm working on an application using XML with DOM. I'm writing and reading data from the file. Both works but the problem is, that the file first actualizises after the application is closed. 
  For reading I use this:</p>
  
  <pre><code>        try {
  
          DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
          DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
          File inputFile = new File("calendar.xml");
          doc = dBuilder.parse(inputFile);
          doc.getDocumentElement().normalize();
          System.out.println("File read in!");
          System.out.println("-----------------------------");
          users = doc.getElementsByTagName("user");
      } catch (Exception e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>And for writing the date I use this:</p>
  
  <pre><code>        try {
          TransformerFactory transformerFactory = TransformerFactory.newInstance();
          Transformer transformer = transformerFactory.newTransformer();
          DOMSource source = new DOMSource(doc);
          StreamResult result = new StreamResult(new File("calendar.xml"));
          transformer.transform(source, result);
      }catch (Exception e){}
  </code></pre>
  
  <p>Actually both works, but I don't know how to refresh the XML-File while the application is running, so that I can read my changes. </p>
  
  <p>So if I got this for example:</p>
  
  <pre><code>&lt;root&gt;
  &lt;child id="1"/&gt;
  &lt;child id="2/"&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>And than I add a new child with the id "3" it stays this:</p>
  
  <pre><code>&lt;root&gt;
  &lt;child id="1"/&gt;
  &lt;child id="2/"&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>First after it's finished the file is:</p>
  
  <pre><code>&lt;root&gt;
  &lt;child id="1"/&gt;
  &lt;child id="2/"&gt;
  &lt;child id="3"/&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>But I want this last result while th application is running.</p>
  
  <p>Help would be nice :)
  Reiswaffl</p>