in reply to Re^3: XML::Simple troubles
in thread XML::Simple troubles

Apologies, you were correct, the script:
#!/usr/bin/perl use strict; use warnings; use XML::Simple; use Data::Dumper; use LWP::Simple; my $Document =XMLin("foo.xml"); while (my ($key, $val) = each %{$Document->{Placemark}}) { printf "%s is at %s\n", $key, $val->{Point}{coordinates}; }
does work. I had updated incorrectly the XML file, thankyou for that.

Now that I can get the info from an XML file stored locally I tried to get the file when stored on a web server.
I used this script but it says that the file does not exist!
Any clues?

#!/usr/bin/perl use strict; use warnings; use XML::Simple; use Data::Dumper; use LWP::Simple; use XML::Parser; my $url= "http://xweb.geos.ed.ac.uk/~s0341330/foo.xml"; my $foo = get ($url) or die "I can't get the feed you want"; my $parser = XML::Simple->new( ); my $Document =$parser->XMLin('$foo'); while (my ($key, $val) = each %{$Document->{Placemark}}) { printf "%s is at %s\n", $key, $val->{Point}{coordinates}; }

Many thanks

Niall

Replies are listed 'Best First'.
Re^5: XML::Simple troubles
by moritz (Cardinal) on May 27, 2008 at 09:13 UTC
    my $Document =$parser->XMLin('$foo');

    So you're trying to open a file named $foo - that won't work. Remove the single quotes.