播客似乎没有一致的方式来定义他们的RSS提要.
进入一个为RSS使用不同模式defs的人.
进入一个为RSS使用不同模式defs的人.
使用XML :: LibXML在RSS URL中扫描xmlnamespace的最佳方法是什么
例如.
一个饲料可能是
<RSS xmlns:content="http://purl.org/RSS/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/RSS/1.0/modules/syndication/" xmlns:slash="http://purl.org/RSS/1.0/modules/slash/" version="2.0">
另一个可能是
<RSS xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
我想在我的脚本中包含对所使用的所有命名空间的评估,以便在解析rs时,可以跟踪相应的字段名称.
解决方法
我不确定我到底知道你正在寻找什么样的输出,但
XML::LibXML
确实能够列出命名空间:
use warnings; use strict; use XML::LibXML; my $dom = XML::LibXML->load_xml(string => <<'EOT'); <RSS xmlns:content="http://purl.org/RSS/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/RSS/1.0/modules/syndication/" xmlns:slash="http://purl.org/RSS/1.0/modules/slash/" version="2.0"> </RSS> EOT for my $ns ($dom->documentElement->getNamespaces) { print $ns->getLocalName()," / ",$ns->getData(),"\n"; }
输出:
content / http://purl.org/RSS/1.0/modules/content/ wfw / http://wellformedweb.org/CommentAPI/ dc / http://purl.org/dc/elements/1.1/ atom / http://www.w3.org/2005/Atom sy / http://purl.org/RSS/1.0/modules/syndication/ slash / http://purl.org/RSS/1.0/modules/slash/