We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
我不确定它是否曾经是“推荐的库”。如果我知道需要解析哪种类型的提要,我会使用 XML::RSS或 XML::Atom (视情况而定),但如果(更有可能)我只是知道这是一个网络提要,我使用 XML::Feed。
根据要求添加使用 XML::Feed 的示例。
这几乎都是从模块文档中复制的。
I'm not sure it's ever been the "recommended library". If I know which kind of feed I need to parse, I use XML::RSS or XML::Atom as appropriate, but if (as is more likely) I just know it's a web feed, I use XML::Feed.
Adding an example of using XML::Feed as requested..
This is all pretty much copied from the module documentation.
实际上,现在我喜欢避免使用特定于域的 XML 解析器,而只使用 XPath 来处理所有事情。这样我只需要记住一个 API 即可。 (除非它是一个巨大的 XML,否则我将使用基于事件的解析器,例如 XML::Parser。 )
因此,使用 XML::XPath,我可以从 RSS 文件中获取一堆内容,如下所示
:世界上最漂亮的代码,但它确实有效。
I actually like to avoid domain-specific XML parsers these days and just use XPath for everything. That way I only have to remember one API. (Unless it's a huge XML, then I'll use an event-based parser like XML::Parser.)
So using XML::XPath, I can grab a bunch of stuff from an RSS file like this:
Not the prettiest code in the world, but it works.
如果 XML::RSS::Parser 适合您,那么就使用它。我已经使用 XML::Parser 来处理 RSS,但我的要求很窄,并且 XML::Parser 已经安装了。
仅仅因为某些东西在几年内进行了更新并不意味着它不再起作用;而是意味着它不再有效。我认为各种 RSS/Atom 规范最近没有改变,所以解析器不需要改变。
If XML::RSS::Parser works for you then use it. I've used XML::Parser to deal with RSS but I had narrow requirements and XML::Parser was already installed.
Just because something has been updated in a few years doesn't mean that it doesn't work anymore; I don't think the various RSS/Atom specs have changed recently so there's no need for the parser to change.
还有一个非常好的模块,名为
XML::FeedPP
(请参阅 http://search.cpan.org/dist/XML-FeedPP/lib/XML/FeedPP.pm)。FeedPP
速度没有那么快,但它几乎是用纯 Perl 编写的,并且具有极简的依赖性。There is also a very nice module called
XML::FeedPP
(see http://search.cpan.org/dist/XML-FeedPP/lib/XML/FeedPP.pm).FeedPP
is no so fast but it writen in almost pure Perl and has minimalistic dependencies.