View Full Version : Perl- Access XML Document Online
Holmes89
May 13th, 2009, 08:57 PM
I'm kind of new to Perl and had a question regarding accessing an online file. If I want to access an XML sheet how to I access it with Perl. I've tried downloading the file with wget but it won't save. So any ideas? Thanks in advance.
myrtle1908
May 13th, 2009, 11:31 PM
Have a look at the LWP modules. A very basic example of how to grab something off of the web follows:-
use strict;
use warnings;
use LWP::Simple;
my $url = 'http://somewhere.com/somefile.xml';
my $xml = get($url);
die "Can't connect to $url" unless defined $xml;
print $xml;
If you need to parse the XML then there are a great many parsers available for Perl. Search around.
KyleBrandt
May 14th, 2009, 02:39 PM
I like XML::Simple, but you are not going to have an easy time with this until you are comfortable with references in Perl. If you don't know references well look at : http://perldoc.perl.org/perlref.html . These can be a little tricky if you have never worked with something like pointers in c , so be patient and read slow.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.