Prev: Writing to the end of a record
Next: worst concept in computer science [Was: to RG - Lisp lunacyand Perl psychosis]
From: Peter Makholm on 12 Mar 2010 05:07 For a project I receive some XML fragments from a data base and have to include it in a larger XML document created with XML::LibXML. With version 1.66 of XML::LibXML I was able to to something like 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>peter(a)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
From: Peter Makholm on 12 Mar 2010 05:38 Peter Makholm <peter(a)makholm.net> writes: > my $node = XML::LibXML->new()->parse_balanced_chunk( > '<owner>peter(a)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>peter(a)makholm.net</owner>' ); for my $node ($fragment->childNodes) { $root->addChild($node); } It works in both XML::LibXML version 1.66 and 1.70. //Makholm
From: Permostat on 12 Mar 2010 08:41
On Mar 12, 4:38 am, Peter Makholm <pe...(a)makholm.net> wrote: > Peter Makholm <pe...(a)makholm.net> writes: > > my $node = XML::LibXML->new()->parse_balanced_chunk( > > '<owner>pe...(a)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...(a)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- |