in reply to Print out an XML file to browser
Here are two options:
- send the xml to the browser, and let the browser render it:
use CGI qw(:cgi); # don't need HTML, only cgi stuff print header(-type => 'application/xml'); # make browser expect xml open XML, '<', 'foo.xml' or die $!; print while <XML>;
- print an HTML rendering of your xml file:
use CGI qw(:standard); sub escape_xml ($) { my $text = shift; $text =~ s/</</g; $text =~ s/
<>/>/g; return $text; } print header, start_html('XML File'); open XML, '<', 'foo.xml' or die $!; print "<pre>\n"; print escape_xml($_) while <XML>; print "\n</pre>";
In Section
Seekers of Perl Wisdom