On Tue, Jul 13, 2010 at 10:00 AM, Barih Uri <uri.ba...@comverse.com> wrote:

>  Hi
> I am new user
>

Hi!

Welcome!

Regarding your question: the major problem with XML::LibXML (which is the
most recommended module, as far as I know), is the documentation of it.

What you were missing is setDocumentElement, which sets the root for the
XML.

This does what you wanted:
----
#!/usr/bin/perl

use strict;
use warnings;
use XML::LibXML;

my $doc  = XML::LibXML::Document->new('1.0');
my $root = $doc->createElement('books');
$doc->setDocumentElement($root);

my $computer = $doc->createElement('computer');
$root->appendChild($computer);

# or change this to toFile()
print "Document: ", $doc->toString, "\n";
----

Sawyer.
_______________________________________________
Perl mailing list
Perl@perl.org.il
http://mail.perl.org.il/mailman/listinfo/perl

Reply via email to