title: HtmlAgilityPack - Keep text position upon removal of node
body: <p>When I remove a node (with <code>keepGrandChildren</code>) that has both text and child nodes inside, the text  is pushed all the way after the child nodes, rather than stay in its original location.</p>
  
  <p><strong>Example:</strong></p>
  
  <pre><code>var doc = new HtmlDocument();
  doc.LoadHtml(@"
  &lt;span id='first'&gt;
      This text comes first.
      &lt;span id='second'&gt;This text comes second.&lt;/span&gt;
  &lt;/span&gt;");
  
  var node = doc.GetElementbyId("first");
  node.ParentNode.RemoveChild(node, true);
  doc.Save(Console.Out);
  </code></pre>
  
  <p>The output that I get is:</p>
  
  <pre><code>    &lt;span id='second'&gt;This text comes second.&lt;/span&gt;
          this text comes first.
  </code></pre>
  
  <p>Instead of:</p>
  
  <pre><code>    this text comes first.
      &lt;span id='second'&gt;This text comes second.&lt;/span&gt;
  </code></pre>
  
  <p><br>
  <strong>Is there any way of removing a node using <code>keepGrandChildren</code> without the text inside getting pushed towards the end?</strong><br>
  I want to conserve <em>absolute</em> order and make sure that no text or nodes change their original position, otherwise the document will be ruined.</p>
  
  <p><em>Edit:</em>
  I'm using <code>HtmlAgilityPack 1.4.6.0</code> and <code>.NET 4.0</code></p>