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