使用xml—writer
#!c:\perl\binuse XML::Writer;
use IO;
#open file stream .Param is file name.
my $output = new IO::File(">output.xml");
#new a output stream.
my $writer = new XML::Writer(OUTPUT => $output)
or die"create fail";
print "file create success!";
#seting xml encoding . version is 1.0.
$writer->xmlDecl("GB2312");
#seting enter
$writer->setDataIndent("\n");
#seting first class start tag
$writer->startTag("root");
#fill in \n
$writer->characters("\n");
#seting seconly class start tag
$writer->startTag("child");
#seting third class start tag
$writer->dataElement("count","123");
$writer->dataElement("name","sss");
#seting seconly class end tag
$writer->endTag("child");
$writer->characters("\n");
$writer->startTag("child");
$writer->dataElement("count","123");
$writer->dataElement("name","sss");
$writer->endTag("child");
$writer->characters("\n");
#seting first class end tag
$writer->endTag("root");
#close writer stream
$writer->end();
#close output stream
$output->close();