Introduction to perl's xml Processing Module

Source: Internet
Author: User

1. Search for existing modules
Http://search.cpan.org/

2. Input an XML query and select a module that has a high rating and can meet your needs:
XML: Simple
Use warnings;
Use XML: Simple;
Use Data: Dumper;

# Converting XML files into Hash results

Copy codeThe Code is as follows: my $ xml = XMLin ('abstract _ sample. xml ');
Open (HASH, '> XML_hash') | die "can not open the file: $! ";
Print HASH Dumper ($ xml );

# Obtain the value of a node in XML according to the path defined in XML.

Copy codeThe Code is as follows: print $ xml-> {PubmedArticle}-> {MedlineCitation}-> {PMID };

# You can re-convert XML into a Hash structure to XML output, but note that the converted XML may be different from the external structure of the original XML file.

Copy codeThe Code is as follows: $ MeSH_XML = XMLout ($ xml-> {PubmedArticle}-> {MedlineCitation}-> {MeshHeadingList });
Print $ MeSH_XML;

For more information, see:
Http://search.cpan.org /~ Grantm/XML-Simple-2.18/lib/XML/Simple. pm

XML: Smart

My $ xml = XML: Smart-> new ('abstract _ sample. xml ');

For more information, see:
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.