示例代码:
<link rel="alternate" type="application/rss+xml" title="Fit Living Lifestyle » 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 » 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"]/@titleThe XPath you are looking for is:
link[@type="application/rss+xml"]/@hrefThis 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更多推荐
发布评论