Created
July 10, 2011 12:09
-
-
Save thinkhy/1074492 to your computer and use it in GitHub Desktop.
insertAfter for MSXML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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