Here is a code sample that reproduces the behaviour I wonder about:
#!/usr/bin/perl
use strict;
use warnings;
use XML::LibXML;
my $myXMLdocument = XML::LibXML::Document->new();
my $myXML = $myXMLdocument->createElement("myXML");
$myXMLdocument->addChild($myXML);
my $element = $myXMLdocument->createElement("element");
$myXML->addChild($element);
my $node = $myXMLdocument->createElement("node");
$element->addNewChild('', $node);
$node->addNewChild('', $myXMLdocument->createAttribute( "key" => "value"));
print "$myXMLdocument->toString(2)\n";
The output :
XML::LibXML::Document=SCALAR(0x8f5a6f8)->toString(2)
I understand that this is some sort of handle for the document structure passed around by XML::LibXML
.
Now why doesn't toString
serialize it to human readable XML?
I may be extremely naïve about XML::LibXML
; this is my first time using it instead of spewing out random XML with Bash's echo.