Quantcast
Channel: XML reading using Perl - Stack Overflow
Viewing all articles
Browse latest Browse all 5

Answer by Nikhil Jain for XML reading using Perl

$
0
0
Use XML::Simple - Easy API to maintain XML (esp config files) or see XML::Twig - A perl module for processing huge XML documents in tree mode.

Example like:

use strict;use warnings;use XML::Simple;use Data::Dumper;my $xml = q~<xml><date><date1>2012-10-22</date1><date2>2012-10-23</date2></date></xml>~;print $xml,$/;my $data = XMLin($xml);print Dumper( $data );my @dates;foreach my $attributes (keys %{$data->{date}}){  push(@dates, $data->{date}{$attributes})}print Dumper(\@dates);

Output:

$VAR1 = ['2012-10-23','2012-10-22'        ];

Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>