【问题标题】:Mojo::DOM: Do some characters need special escaping?Mojo::DOM: 某些字符需要特殊转义吗?
【发布时间】:2012-04-27 11:24:40
【问题描述】:

为什么media:group虽然出现在dom中却不起作用?

#!/usr/bin/env perl
use warnings;
use 5.12.0;
use Mojo::UserAgent;

my $ua = Mojo::UserAgent->new();

my $id = 'E7511681ABEA8635';
my $url = 'http://gdata.youtube.com/feeds/api/playlists/' . $id . '?v=2';
my $tx = $ua->get( $url );

say $tx->res->dom->at( 'category' )->type;
say $tx->res->dom->at( 'media:group' )->type;

# category
# Can't call method "type" on an undefined value at ./perl.pl line 13

【问题讨论】:

    标签: perl dom mojolicious


    【解决方案1】:

    因为 media: 是命名空间吗?如果您将最后一行更改为 at('group') 它会返回 'media:group'

    【讨论】:

    • 这也有效:say $tx->res->dom->at( 'media\:group' )->type;
    猜你喜欢
    • 2013-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-23
    • 2011-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多