M
miletwo
I'm trying to read xml file and rewrite as RSS using following file.
Problem is, it is not forcing UTF-8 no matter what I do. Any help
appreciated.
***********************
#!/bin/perl -w
#use strict;
use XML::Twig;
use utf8;
use open OUT => ":utf8";
use open IN => ":utf8";
my $shownum = 10;
my $thisyear = '2006';
my $field= 'releasedate';
my $twig= new XML::Twig( keep_encoding=> 1);
open(INFILE, "directorylist.xml");
$twig->parse(\*INFILE);
my $root= $twig->root;
my @releases= $root->children;
my $output = "";
$output .= '<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n";
$output .= '<channel>' . "\n\n";
$output .= <<EOT;
<title>scrubbed Incorporated - Recent News</title>
<link>http://www.scrubbed.com/press/</link>
<description>Visit the scrubbed Press Center where you will find
many resources, including press releases, corporate information,
technology overviews, executive bios and photos, the scrubbed logo and
more.<br />If you are a member of the media and are not able to find
what you are looking for in the Press Center, please send an email to
corpcomm\@scrubbed.com.</description>
<language>en-us</language>
EOT
for(my $i=0; $i < $shownum; $i++){
$output .= "\t" . '<item>' . "\n";
$output .= "\t\t" . '<title>' .
$releases[$i]->first_child('headline')->text . '</title>' . "\n";
$output .= "\t\t" . '<link>http://www.scrubbed.com/press/releases/' .
$thisyear . '/' . $releases[$i]->att('name') . '.html</link>' . "\n";
$output .= "\t\t" . '<description>' .
$releases[$i]->first_child('subheader')->text . '</description>' .
"\n";
$output .= "\t\t" . '<dc:date>' .
$releases[$i]->first_child('releasedate')->text . '</dc:date>' . "\n";
$output .= "\t" . '</item>';
$output .= "\n\n";
}
$output .= "</channel>\n</rss>";
Encode::_utf8_on($output);
open(FILEWRITE,">:utf8", "press.rss");
binmode FILEWRITE, ":utf8";
print FILEWRITE $output;
Problem is, it is not forcing UTF-8 no matter what I do. Any help
appreciated.
***********************
#!/bin/perl -w
#use strict;
use XML::Twig;
use utf8;
use open OUT => ":utf8";
use open IN => ":utf8";
my $shownum = 10;
my $thisyear = '2006';
my $field= 'releasedate';
my $twig= new XML::Twig( keep_encoding=> 1);
open(INFILE, "directorylist.xml");
$twig->parse(\*INFILE);
my $root= $twig->root;
my @releases= $root->children;
my $output = "";
$output .= '<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n";
$output .= '<channel>' . "\n\n";
$output .= <<EOT;
<title>scrubbed Incorporated - Recent News</title>
<link>http://www.scrubbed.com/press/</link>
<description>Visit the scrubbed Press Center where you will find
many resources, including press releases, corporate information,
technology overviews, executive bios and photos, the scrubbed logo and
more.<br />If you are a member of the media and are not able to find
what you are looking for in the Press Center, please send an email to
corpcomm\@scrubbed.com.</description>
<language>en-us</language>
EOT
for(my $i=0; $i < $shownum; $i++){
$output .= "\t" . '<item>' . "\n";
$output .= "\t\t" . '<title>' .
$releases[$i]->first_child('headline')->text . '</title>' . "\n";
$output .= "\t\t" . '<link>http://www.scrubbed.com/press/releases/' .
$thisyear . '/' . $releases[$i]->att('name') . '.html</link>' . "\n";
$output .= "\t\t" . '<description>' .
$releases[$i]->first_child('subheader')->text . '</description>' .
"\n";
$output .= "\t\t" . '<dc:date>' .
$releases[$i]->first_child('releasedate')->text . '</dc:date>' . "\n";
$output .= "\t" . '</item>';
$output .= "\n\n";
}
$output .= "</channel>\n</rss>";
Encode::_utf8_on($output);
open(FILEWRITE,">:utf8", "press.rss");
binmode FILEWRITE, ":utf8";
print FILEWRITE $output;