如何使用Xpath获取RSS URL(How do I pick up RSS URLs using Xpath)

系统教程 行业动态 更新时间:2024-06-14 16:57:40
如何使用Xpath获取RSS URL(How do I pick up RSS URLs using Xpath)

示例代码:

<link rel="alternate" type="application/rss+xml" title="Fit Living Lifestyle &raquo; Feed" href="http://www.fitlivinglifestyle.com/feed/" />

我如何检查type="application/rss+xml" XPATH,如果它存在,则返回URL: http://www.fitlivinglifestyle.com/comments/feed/ : http://www.fitlivinglifestyle.com/comments/feed/ (甚至标题属性也是如此)

我尝试了一些变化:

//@href[parent::link[contains(@type='application/rss+xml',//@href)]]

但似乎并不完全存在。

Example code:

<link rel="alternate" type="application/rss+xml" title="Fit Living Lifestyle &raquo; Feed" href="http://www.fitlivinglifestyle.com/feed/" />

How do I have XPATH check for type="application/rss+xml" and if it is present then return me the URL: http://www.fitlivinglifestyle.com/comments/feed/ (and even the title attribute too)

I have tried some variations of this:

//@href[parent::link[contains(@type='application/rss+xml',//@href)]]

But don't seem to be quite there.

最满意答案

您正在寻找的XPath是:

link[@type="application/rss+xml"]/@href

这将选择type="application/rss+xml"所有link元素并返回href属性。 要返回title属性,请使用:

link[@type="application/rss+xml"]/@title

The XPath you are looking for is:

link[@type="application/rss+xml"]/@href

This selects all link elements with type="application/rss+xml" and returns the href attribute. To return the title attribute use:

link[@type="application/rss+xml"]/@title

更多推荐

本文发布于:2023-04-13 12:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/f3971b0c5322755d78f6a38dee5cb6b7.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   Xpath   RSS   URLs   pick

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!