Introduction to Perl processing XML modules _perl

Source: Internet
Author: User

1. Find existing Modules
http://search.cpan.org/

2. Input XML query, select the higher evaluation, and can meet their own needs of modules:
Xml::simple
Use warnings;
Use Xml::simple;
Use Data::D umper;

#将XML文件转化为Hash结果

Copy Code code as follows:

My $xml =xmlin (' abstract_sample.xml ');
Open (HASH, ' >>xml_hash ') | | Die "Can not open the file: $!";
Print HASH dumper ($xml);

#想访问XML某个节点的值, you need to obtain an XML-defined path based on the

Copy Code code as follows:
Print $xml->{pubmedarticle}->{medlinecitation}->{pmid};

#可以将XML转化为的Hash结构重新转换为XML输出, but be aware that the transformed XML may be different from the original XML file appearance

Copy Code code as follows:
$MeSH _xml=xmlout ($xml->{pubmedarticle}->{medlinecitation}->{meshheadinglist});
Print $MeSH _xml;

For more use, refer to:
http://search.cpan.org/~grantm/XML-Simple-2.18/lib/XML/Simple.pm

Xml::smart

My $xml =xml::smart->new (' abstract_sample.xml ');

More usage References:
http://search.cpan.org/~gmpassos/XML-Smart-1.6.9/lib/XML/Smart.pm

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.