Hi,

i am trying to create a xml file with the following

 <?xml version="1.0" encoding="UTF-8"?>
<file name="file 1"/>
 <file name="file 2"/>

i try the following code without any success, can someone help me to
understand what i am dong wrong?

use strict;
use XML::LibXML;

my $doc = XML::LibXML::Document->new( '1.0', 'UTF-8' );
my $root = $doc->createElementNS('', 'file');
my $attr = $doc->createAttributeNS( "", "name", "file 1" );
$root->setAttributeNodeNS( $attr );
$doc->setDocumentElement($root);
print "\n\n ";
print $doc->toString(2);
print "\n\n ";

my $root2 = $doc->createElementNS('', 'file');
my $attr2 = $doc->createAttributeNS( "", "name", "file 2" );
$root2->setAttributeNodeNS( $attr2 );
$doc->setDocumentElement($root2);
print "\n\n ";
print $doc->toString(2);
print "\n\n ";

the result is

 <?xml version="1.0" encoding="UTF-8"?>
<file name="file 1"/>


 <?xml version="1.0" encoding="UTF-8"?>
<file name="file 2"/>

Regards Zacky


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to