my $doc = XML::LibXML::Document->new('1.0', 'utf-8' );
my $root = $doc->createElement("X:root");
$doc->setDocumentElement($root);
my $node = XML::LibXML->new()->parse_balanced_chunk(
'<owner>pe...@makholm.net</owner>'
);
$doc->adoptNode($node);
$root->addChild($node);
But with version 1.70 of XML::LibXML this fails with an error saying
'Adding document fragments with addChild not supported!'
Is there a working way to implement this?
//Makholm
> my $node = XML::LibXML->new()->parse_balanced_chunk(
> '<owner>pe...@makholm.net</owner>'
> );
> $doc->adoptNode($node);
> $root->addChild($node);
After a bit more trying I can up with this solution:
my $fragment = XML::LibXML->new()->parse_balanced_chunk(
'<owner>pe...@makholm.net</owner>'
);
for my $node ($fragment->childNodes) {
$root->addChild($node);
}
It works in both XML::LibXML version 1.66 and 1.70.
//Makholm
Well aren't you just a hunky dory Fucker.
sperm-