Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Perl and XML

by jeffa (Bishop)
on Mar 16, 2004 at 23:08 UTC ( #337156=note: print w/replies, xml ) Need Help??


in reply to Perl and XML

To elaborate on what bart said, you have to print out a Content Header if you want to view this as a web page from a browser. One easy way is to use CGI.pm:
use strict; use XML::Simple; use CGI qw(header); print header('text/plain'); my $xs1 = XML::Simple->new(); my $doc = $xs1->XMLin('files/camelids.xml'); foreach my $key (keys (%{$doc->{species}})){ print $doc->{species}->{$key}->{'common-name'} . " ($key) "; print $doc->{species}->{$key}->{conservation}->{status} . "\n"; }
You also have to make sure that the CGI file is executable by everyone ... "chmod 755 foo.cgi" should do the trick if you have command line access.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: Re: Perl and XML
by BzBeauty (Sexton) on Mar 16, 2004 at 23:19 UTC
    thank you - got it, that was the problem

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://337156]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2019-12-11 00:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?