diptiman has asked for the wisdom of the Perl Monks concerning the following question:

Hi ,

I have written a script to parse an XML file using XML::DOM . But , the problem is , the file has to be retrieved from an URL which is something like : " http://abc.def/xyz.xml " I have tried adding it to ARGV[0] . But, then it does not work. The script needs to run in the following way :

perl parsingscript.pl http://abc.def/xyz.xml

The way I tried was :

my $file = 'http://abc.def/xyz.xml ' my $doc = $parser->parsefile($file)

But, this does not work.

Could you tell me please, how to retrieve this XML file from this URL and parse it by using it as a commmand line argument ?

Edited 2002-06-24 by mirod:added code and p tags

Replies are listed 'Best First'.
Re: source XML as URL in command line
by mattriff (Chaplain) on Jun 24, 2002 at 04:01 UTC
    Use LWP to get the file first, then call the parser on it. The first recipe in lwpcook shows a simple way to retrieve the file.

    There's also a whole book devoted to LWP (not that you need a book for such a simple task).

    - Matt Riffle

Re: source XML as URL in command line
by Matts (Deacon) on Jun 24, 2002 at 07:10 UTC
    Switch to XML::LibXML instead. Then it'll just work (though parsefile() becomes parse_file()).