I write the following (DOM) Perl script (shown below) in order to create the following XML DOM:
<books>
<computer/>
</books>
How can I save the XML output into test.xml
file? I tried to save the XML with
$doc->printToFile('/tmp/test.xml');
but I get:
can't locate object method "printToFile" via package "XML::LibXML::Document"
The Perl script:
#!/usr/bin/perl
use XML::LibXML;
my $doc;
$doc = XML::LibXML::Document->new;
my $objbooks = $doc->createElement('books');
$doc->appendChild($objbooks);
my $objcomputer = $doc->createElement('computer');
$objbooks->appendChild($objcomputer);