且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用xsl regex替换RSS链接中的href

更新时间:2023-02-18 13:12:52

也许我误解了你...你想要更换href(ok),但输出应该是什么? (rss再次或html)


进行简单的替换我会尝试
Maybe I''ve misunderstood you... you want to replace the href (ok), but what should the output be? (rss again or html)

for a simple replace I''d try
展开 | 选择 | 换行 | 行号


对不起,它应该像我的其余XSL一样输出HTML。



另外,我不是要替换< TITLE>中的href。但在< DESCRIPTION>


用我已经有效的变量替换标题中的href,虽然这是另一个很好的解决方案。


相反,我试图替换< DESCRIPTION>中的href。这可能是一种更简单的方法,因为我已经可以在其中分配带有变量的链接,以便去掉< DESCRIPTION>的img src。用正确的href包装它?


我希望这有意义!?!?!
Ahhh sorry, IT SHOULD OUTPUT HTML as with the rest of my XSL.


Also I am not trying to replace the href in <TITLE> but in <DESCRIPTION>

to replace the href in the title with the variable i already have that working, although this is another great solution.

Rather i am trying to replace the href in the <DESCRIPTION> with the same virable.

It may be an easier approach since I can already assign the link with the variable in it to just strip out the img src of the <DESCRIPTION> and wrap it with the correct href?

I hope this makes sense!?!?!



我也不是要替换< TITLE>中的href。但在< DESCRIPTION>中
Also I am not trying to replace the href in <TITLE> but in <DESCRIPTION>



对不起,但我不明白这一点......据我所知,里面没有href< title>。 br />

sorry, but I don''t get the point here... as far as I can see there''s no href inside <title>.


相反,我试图替换< DESCRIPTION>中的href。同样可行的。
Rather i am trying to replace the href in the <DESCRIPTION> with the same virable.



但由于你想输出html,可能是替换不是***的描述(我不得不承认它让我感到困惑)。此外,如果您想将img作为链接内容,您可以使用< xsl:copy> (当然可以根据需要随意调整xpath)

只是为了清晰...你想使用来自< enclosure>的uri和< description>?的img需要注意的是你使用正确的xpath表达式(对于你有这个设置的uri和你可以使用item / description / a / img访问的img,只需将这两个放在你的模板中即可得到了它

but since you want to output html, maybe "replace" is not the best description (I have to admit it confuses me a little). Furthermore if you want the img as link content you may use <xsl:copy> (and of course feel free to tweak the xpath as you need it)
just for clarity... you want to use the uri from <enclosure> and the img of <description>? the thing to take care of is that you use the right xpath expressions (for the uri you have this set up and the img you can access with "item/description/a/img", just put these two in your template and you''ve got it)