I am using a script below which I paid a web developer to write for me as I'm predominantely a designer with html skills and my knowledge of perl and xml is very limited.
The script processes an xml feed from another site and creates a cache file.
However when the xml is cached the code ' is stored instead of an apostrophe and as a consequence this is displayed on the site when the script is called.
For example "John's Performance" is displayed as "John's Performance". The apostrophe tends to occur in the <event_desc></event_desc>.
I'd be really grateful if anyone could advise what change I need to make to the script below in order for it to replace ' with a '.
I've done a search on google and it seems that ' is used in xml to denote and apostrophe but is not supported in html.
I would ask my developer to fix, but he is very expensive and said it would cost £50 to fix. Is this reasonable?
#!/usr/local/bin/perl -w
use strict;
use CGI qw(:all);
#use Fcntl qw(:flock);
use LWP::Simple qw(get);
my $xml_url = "http://www.domain-name.com/cgi-bin/search.exe&chan=xml";
my $newscache = "cache.xml";
########################################
# enter number of articles to include
my $howmanyarticles = "60";
########################################
# write the cache file or
# if the cache file is older than 1 hour
# then re-write it.
#get_lock();
if ((not -e $newscache) or (-M $newscache > .5)) { # (not -e) if the cache file doesn't exist, -M gives the modification time since creation, 1 is 1 day, 0.04 is about 1 hour.
my $newsdoc = get($xml_url);# uses the LWP module "get" function to get the XML file.
if (defined $newsdoc) {
open (CACHEFILE, ">$newscache") ¦¦ die "Writing to Cache : $!";
print CACHEFILE $newsdoc;
close (CACHEFILE);
}
}
#release_lock();
########################################
# now print the contents of the XML file
print header;
print "<table width=\"100%\" align= center border=\"0\" cellpadding=\"4\" cellspacing=\"0\">";
open (CF, "$newscache") ¦¦ die "Unable to open $newscache : $!";
my ($eventname, $eventvenue);
my $counter =0;
while (<CF>) {
if (m,<event_desc>(.*)</event_desc>,) {
$eventname = $1;
}
if (m,<venue_desc>(.*)</venue_desc>,) {
$eventvenue = $1;
}
if (m,<crypto_block>(.*)</crypto_block>,) {
print "
<tr>
<td valign=\"top\"><a href=\"$1\">$eventname</a></td><td>$eventvenue</td>
";
$counter++;
last if $counter == $howmanyarticles;
}
}
close(CF);
print "
<tr>
<td width=\"100\%\" colspan=\"4\" height=\"10\"></td>
</tr>
</table>
";
# END