Subject: | appendTextNode not working on $elem=XML::LibXML::Element->new("bar"); |
With XML-LibXML 1.31 on perl 5.6.1, Solaris 2.7 the following
looks very strange to me:
use XML::LibXML;
use Data::Dumper;
my $elem1 = XML::LibXML::Element->new("bar");
my $vers='1.0';
my $enc= 'utf8';
my $dom = XML::LibXML::Document->createDocument( $vers, $enc );
my $elem2 = $dom->createElement('bar' );
add_and_display($elem1);
add_and_display($elem2);
sub add_and_display {
my ($element) = @_;
$element->setAttribute("color" => "blotchy purply");
$element->appendTextChild('foo', "test test test.");
$element->appendTextNode("test test test ");
$element->appendText("test test test");
print $element->toString() . "\n";;
print "$element\n";
print Dumper($element);
}
gives as output :
<bar color="blotchy purply"><foo>test test test.</foo></bar>
XML::LibXML::Element=SCALAR(0x11c07c)
$VAR1 = bless( do{\(my $o = 2052528)}, 'XML::LibXML::Element' );
<bar color="blotchy purply"><foo>test test test.</foo>test test test test test test</bar>
XML::LibXML::Element=SCALAR(0x1fbe78)
$VAR1 = bless( do{\(my $o = 2052568)}, 'XML::LibXML::Element' );
When the element is created as a XML::LibXML::Element-new, the appendText
does not work. If it is created with $dom->createElement, it does.
Is this expected, I cannot find this behaviour in the docs.