title: Edit a XML file in java
body: <p>I have the following XML file:</p>
  
  <pre><code>&lt;Tables&gt;
      &lt;table&gt;
          &lt;row&gt;&lt;/row&gt;
      &lt;/table&gt;
  &lt;Tables&gt;
  </code></pre>
  
  <p>and I want to edit it to :</p>
  
  <pre><code>&lt;Tables&gt;
      &lt;table&gt;
          &lt;row&gt;some value&lt;/row&gt;
      &lt;/table&gt;
  &lt;Tables&gt;
  </code></pre>
  
  <p>I write the XML file using file writer. How can I edit it?</p>
  
  <p>What I was found that I create a temp file contains edits then delete the original file and rename the temp file. Is there any other way?</p>
  
  <p>that's my code to write the file:</p>
  
  <pre><code>public boolean createTable(String path, String name, String[] properties) throws IOException {
      FileWriter writer = new FileWriter(path);
      writer.write("&lt;Tables&gt;");
      writer.write("\t&lt;" + name + "&gt;");
      for(int i=0; i&lt;properties.length; i++){
          writer.write("\t\t&lt;" + properties[0] + "&gt;&lt;/" + properties[0] + "&gt;");
      }
      writer.write("\t&lt;/" + name + "&gt;");
      writer.write("&lt;/Tables&gt;");
      writer.close();
      return false;
  }
  </code></pre>