perl處理xml的模塊介紹
1. 查找已有的模塊
http://search.cpan.org/
2. 輸入XML查詢,選擇評價較高的,且可以滿足自己需求的模塊:
XML::Simple
use warnings;
use XML::Simple;
use Data::Dumper;
#將XML文件轉(zhuǎn)化為Hash結(jié)果
my $xml=XMLin('abstract_sample.xml');
open(HASH,'>>XML_hash')||die"can not open the file: $!";
print HASH Dumper($xml);
#想訪問XML某個節(jié)點的值,需要根據(jù)XML定義路徑獲取
#可以將XML轉(zhuǎn)化為的Hash結(jié)構(gòu)重新轉(zhuǎn)換為XML輸出,但是需要注意轉(zhuǎn)化后的XML可能和原始的XML文件外表不同了
print $MeSH_XML;
更多使用參看:
http://search.cpan.org/~grantm/XML-Simple-2.18/lib/XML/Simple.pm
XML::Smart
my $xml=XML::Smart->new('abstract_sample.xml');
更多使用參考:
http://search.cpan.org/~gmpassos/XML-Smart-1.6.9/lib/XML/Smart.pm
相關(guān)文章
Windows10下安裝配置 perl 環(huán)境的詳細教程
Perl 最重要的特性是Perl內(nèi)部集成了正則表達式的功能,以及巨大的第三方代碼庫CPAN。這篇文章主要介紹了Windows10下安裝配置 perl 環(huán)境的詳細教程,需要的朋友可以參考下2020-12-12perl中chomp的使用介紹(chop和chomp函數(shù)區(qū)別)
perl程序中,有時在輸入過程中使用chomp才會得到正確的結(jié)果2013-02-02