[Moscow.pm] XML::RSS vs Yandex
Dmitry L.
dim0xff на gmail.com
Пн Фев 23 03:07:10 PST 2015
Там по коду не получится — XML::RSS::Private::Output::Base/_out_ns_tag
Из коробки можно сделать только так:
<prefix:tag key1="val1" key2="val2" ... />
В принципе можно обернуть _out_ns_tag
{
no strict 'subs';
my $orig = \&XML::RSS::Private::Output::Base::_out_ns_tag;
*XML::RSS::Private::Output::Base::_out_ns_tag = sub {
my ( $self, $prefix, $tag, $inner ) = @_;
if ( ref($inner) eq "HASH" && exists( $inner->{__force_out_tag} ) ) {
delete $inner->{__force_out_tag};
return $self->_out_tag( "${prefix}:${tag}", $inner );
}
else {
$orig->(@_);
}
};
}
$rss->channel(
title => $rss_channel_title,
link => $rss_channel_link,
language => 'ru',
description => $rss_channel_description,
lastBuildDate => $lastBuildDate,
copyright => $rss_channel_copyright,
yandex => [
{
el => 'logo',
val => $rss_yandex_logo
},
{
el => 'logo',
val => {
__force_out_tag => 1,
type => 'square',
content => $rss_yandex_logo,
}
},
],
ttl => 60,
);
On 23 February 2015 at 03:42, Nick Knutov <mail на knutov.com> wrote:
> Подскажите, что сделать с XML::RSS, чтобы он позволил добавить
>
> <yandex:logo>http://example.net/logo.png</yandex:logo>
> <yandex:logo type="square">http://example.net/logo.png</yandex:logo>
>
> ?
>
> my $rss = new XML::RSS( version => '2.0', encoding=>'UTF-8',
> encode_output => 0 );
> $rss->add_module(prefix=>'yandex', uri=>'http://news.yandex.ru') if $yandex;
> $rss->channel(
> title => $rss_channel_title,
> link => $rss_channel_link,
> language => 'ru',
> description => $rss_channel_description,
> lastBuildDate => $lastBuildDate,
> copyright => $rss_channel_copyright,
> yandex => {
> logo => $rss_yandex_logo,
> },
> ttl => 60,
> );
>
> Но я так и не смог понять как добавить второй yandex:logo с указанием type
>
>
>
> --
> Best Regards,
> Nick Knutov
> http://knutov.com
> ICQ: 272873706
> Voice: +7-904-84-23-130
> --
> Moscow.pm mailing list
> moscow-pm на pm.org | http://moscow.pm.org
--
//wbr, Dmitry L.
Подробная информация о списке рассылки Moscow-pm