title: Adding a new node before the first child in dom tree
body: <p>This is probably one of those easiest things to deal with but for some reason not working for me. I'm trying to add a new node after the root in dom tree.<br>
  Here's the original string:</p>
  
  <pre><code>&lt;div class="discussionThread dt"&gt;&lt;div class="dt_subject"&gt;2011 IS HERE!&lt;/div&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I'm trying to add a new node which is in the form of a string before . The final version should look like:</p>
  
  <pre><code>&lt;div class="discussionThread dt"&gt;&lt;div class="test"&gt;Test Val&lt;/div&gt;&lt;div class="dt_subject"&gt;2011 IS HERE!&lt;/div&gt;&lt;/div&gt;
  </code></pre>
  
  <p>As you can see, the new <strong>Test Val</strong> is being added immediately after the root div class. I've used few methods to place the node at the right place but its getting appended at the end.</p>
  
  <p>Here's a sample which I referred from one of the earlier posts:</p>
  
  <pre><code>String newNode = "&lt;div class="test"&gt;test&lt;/div&gt;";
  SAXReader reader = new SAXReader();
  Document newNodeDocument = reader.read(new StringReader(newNode));
  Document originalDoc = new SAXReader().read(new StringReader(content));
  Element root = originalDoc.getRootElement();
  Element givenNode = originalDoc.getRootElement(); 
  givenNode.add(newNodeDocument.getRootElement());
  </code></pre>
  
  <p>This is resulting the node getting added at the end. I tried using insertBefore(), but didn't work out.</p>
  
  <p>Any pointers will be highly appreciated.</p>
  
  <p>Thanks </p>