title: insert after child libxml perl
body: <pre><code>&lt;root&gt;
   &lt;element&gt;abc&lt;/element&gt;
  &lt;top&gt;
   &lt;element&gt;after&lt;/element&gt;
  &lt;element&gt;before&lt;/element&gt;
  &lt;/top&gt;
   &lt;element&gt;456&lt;/element&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>I  want to insert another element after element and before element.
  Tried a few variations, must be missing something.</p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  use warnings;
  use XML::LibXML;
  
  my $parser = XML::LibXML-&gt;new;
  my $doc = $parser-&gt;parse_file("mytest.xml");
  my $root = $doc-&gt;getDocumentElement();
  my @node = $doc-&gt;find('//top/element[2]');
  
  my $new_element= $doc-&gt;createElement("element");
  $new_element-&gt;appendText('testing');
  
  $node[0]-&gt;insertAfter($new_element, undef);
  
  print $root-&gt;toString(1);
  </code></pre>