Skip to content

Instantly share code, notes, and snippets.

@thinkhy
Created July 10, 2011 12:09
Show Gist options
  • Save thinkhy/1074492 to your computer and use it in GitHub Desktop.
Save thinkhy/1074492 to your computer and use it in GitHub Desktop.
insertAfter for MSXML
use Win32::OLE qw(in with);
use strict;
use constant MSXMLDOM => "MSXML2.DOMDOCUMENT.4.0";
sub insertAfter{
my($newElement, $targetElement) = @_;
# my $lastChild = $parent->{lastChild};
# Next line can NOT work in Perl.
# if($lastChild && $lastChild == $targetElement)
if (!$targetElement->nextSibling())
{
$parent->appendChild($newElement);
}
else
{
$parent->insertBefore($newElement,$targetElement->nextSibling());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment