Perl is the first XML document to be created.

Source: Internet
Author: User

Use XML-writer

#! C:/perl/bin/
Use 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 ();

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.