Subject: | insertBefore and insertAfter broken |
dist:XML-LibXML-1.56
libxml-version: libxml2-2.5.11 AND libxml2-2.5.10
perlv: v5.8.0
system: Linux 2.2.16-22
Hi,
it seems to me that the methods $node->insertBefore() and $node->insertAfter() are broken. After updating to 1.56 they do not work any more. If I use appendChild() it works fine.
I testet:
$node->insertBefore($newnode, undef);
$node->insertBefore($newnode, $node->getLastChild());
There is nothing inserted to the node. I attached you a script that produces the problem.
#!/usr/bin/perl
use strict;
use XML::LibXML;
my $rows = 10;
my $columns = 10;
my $border = 1;
my $bgcolor="#FFFFFF";
my $cellpadding=0;
my $cellspacing = 0;
my $tablenode = new XML::LibXML::Element('table');
# attribute einfuegen
$tablenode->setAttribute('border', $border) if ($border);
$tablenode->setAttribute('bgcolor', $bgcolor) if ($bgcolor);
$tablenode->setAttribute('cellpadding', $cellpadding) if ($cellpadding);
$tablenode->setAttribute('cellspacing', $cellspacing) if ($cellspacing);
# columns und rows einfuegen
for(my $i=0; $i<$rows; $i++) {
# gewuenschte anzahl an rows erstellen
my $tr = new XML::LibXML::Element('tr');
for(my $cc=0; $cc<$columns; $cc++) {
# gewuenschte Anzahl tds pro tr erzeugen und einfuegen
my $tc = new XML::LibXML::Element('td');
$tr->insertAfter( $tc, $tr->getLastChild() );
}
# aktuelles tr in die Tabelle einfuegen
$tablenode->insertAfter($tr, $tablenode->getLastChild());
}
print $tablenode->toString();
# output: <table border="1" bgcolor="#FFFFFF"/>