Node
[Raku LibXML Project] / [LibXML-Writer Module] / Writer :: Node
class LibXML::Writer::Node
LibXML document fragment/sub-tree construction
Synopsis
use LibXML::Document;
use LibXML::Element;
use LibXML::Writer::Node;
my LibXML::Document $doc .= new;
# concurrent sub-tree construction
my LibXML::Element @elems = (1.10).hyper.map: {
my LibXML::Element $node = $doc.createElement('Bar');
my LibXML::Writer::Node $writer .= new: :$node;
$writer.startDocument();
$writer.startElement('Baz');
$writer.endElement;
$writer.endDocument;
$writer.node;
}
my $root = $doc.createElement('Foo');
$root.addChild($_) for @elems;
$doc.root = $root;
say $writer.Str;
say $doc.Str;
# <?xml version="1.0" encoding="UTF-8"?>
# <Foo><Bar><Baz/></Bar>...</Foo>
Description
This class is used to write sub-trees; stand-alone or within a containing document.