title: Writing from Java to an XML document - Simple
body: <p>I know there's tons of questions on writing from Java to XML on stackoverflow, but it's all too complex. I feel I have a very simple problem that I just can't figure out.</p>
  
  <p>So I have a program that takes a bunch of user input and I have it currently creating and appending a text document with the results. I'll just post my writer code here:</p>
  
  <pre><code> PrintWriter out = null;
           try {
               out = new PrintWriter(new BufferedWriter(new FileWriter("C:/Documents and Settings/blank/My Documents/test/test.txt", true)));
               out.println("");
               out.println("&lt;event title=\""+titleFieldUI+"\"");
               out.println("  start=\""+monthLongUI+" "+dayLongUI+" "+yearLongUI+" 00:00:00 EST"+"\"");            
               out.println("  isDuration=\"true\"");
               out.println("  color=\""+sValue+"\"");
               out.println("  end=\""+monthLong1UI+" "+dayLong1UI+" "+yearLong1UI+" 00:00:00 EST"+"\"");
               out.println("  "+descriptionUI);
               out.println("");
               out.println("&lt;/event&gt;");
               out.println("  &lt;!-- Above event added by: " +System.getProperty("user.name")+" " +
                          "on: "+month+"/"+day+"/"+year+" --&gt;");       
           }catch (IOException e) {
               System.err.println(e);
           }finally{
               if(out != null){
                   out.close();
               }
           } 
  </code></pre>
  
  <p>So in the end, I want it to write to an already existing XML file (which I can do by simply changing where my writer goes to). Problem is, this XML file has ONE root tag known as <code>&lt;data&gt;</code>. I need the results of my program to go on the bottom of the XML file, but come BEFORE <code>&lt;/data&gt;</code>. That's the only requirement. Everything I find seems too complex and I can't figure it out..</p>
  
  <p>Any help is very much appreciated! </p>