Ubuntu 14 Installing the Xml::simple module

Source: Internet
Author: User

Recently need to use Perl to parse the XML file, from the Internet search, most of the recommendations using the Xml::simple module to parse, here to record the installation process

Method One:

Use CPAN to install modules directly

perl -mcpan-e shellcpaninstall  xml::simplecpan> quit

Method Two:

Perform an Ubuntu-brought command installation

Install libxml-simple-perl

Method Three:

Download the source code and install it yourself from CPAN website

1 because the Ubuntu environment is missing a library file, first Apt-get install it yourself

Install Libexpat1-dev

2 Download Install XML::P arser module

Download Link: http://search.cpan.org/CPAN/authors/id/T/TO/TODDR/XML-Parser-2.44.tar.gz

Compiling the installation command

Perl makefile.pl  Make  Make Install

3 Download and install the Xml::sax::expat module

Download Link: http://search.cpan.org/CPAN/authors/id/B/BJ/BJOERN/XML-SAX-Expat-0.51.tar.gz

Compiling the installation command

Perl makefile.pl  Make  Make Install

4 Download and install the Xml::simple module

Download Link: http://search.cpan.org/CPAN/authors/id/G/GR/GRANTM/XML-Simple-2.20.tar.gz

Compiling the installation command

Perl makefile.pl  Make  Make Install

Test Xml::simple Module

XML file

< name >   < SS >ttt</ss></name>

Perl file

 UseXml::Simple ; UseData::dumper;#my $xmlfile = "/home/sequoiadb/misc/autogen/rclist.xml";my $xmlfile="Test.xml";if(-E$xmlfile){   Print "----------------\ n"; my $userxs= Xml::simple->new (keyattr ="name"); my $userxml=$userxs->xmlin ($xmlfile); PrintDumper ($userxml);}

Execute code

Perl readxml.pl

Output

----------------= {          'SS'ttt'         };

Proof of Successful Installation

Reference blog:

http://tilt.lib.tsinghua.edu.cn/node/561

http://site.douban.com/159496/widget/notes/8348910/note/224957070/

http://forum.ubuntu.org.cn/viewtopic.php?t=457163

Ubuntu 14 Installing the Xml::simple module

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.