1
如何获取html表格中的条目/媒体:缩略图/ url值。带命名空间的Youtube频道Feed的XSLT转换
饲料XML:
<feed xmlns:yt="http://www.youtube.com/xml/schemas/2015" xmlns:media="http://search.yahoo.com/mrss/" xmlns="http://www.w3.org/2005/Atom">
<link rel="self" href="http://www.youtube.com/feeds/videos.xml?channel_id=MyChannel"/>
<id>yt:channel:MyChannel</id>
<yt:channelId>MyChannel</yt:channelId>
<title>Jon Smith</title>
<link rel="alternate" href="https://www.youtube.com/channel/MyChannel"/>
<author>
<name>Jon Smith</name>
<uri>
https://www.youtube.com/channel/MyChannel
</uri>
</author>
<published>2007-02-13T04:11:08+00:00</published>
<entry>
<id>yt:video:BQrqsddkSuI_Uo</id>
<yt:videoId>BQrqsskSuI_Uo</yt:videoId>
<yt:channelId>MyChannel</yt:channelId>
<title>Title 1</title>
<link rel="alternate" href="https://www.youtube.com/watch?v=BQrqsddkSusdfdI_Uo"/>
<author>
<name>Jon Smith</name>
<uri>
https://www.youtube.com/channel/MyChannel
</uri>
</author>
<published>2017-07-26T17:41:31+00:00</published>
<updated>2017-08-07T11:17:33+00:00</updated>
<media:group>
<media:title>Title 1</media:title>
<media:content url="https://www.youtube.com/v/BQrqsddskSuI_Uo?version=3" type="application/x-shockwave-flash" width="640" height="390"/>
<media:thumbnail url="https://i3.ytimg.com/vi/BQrqksdsdSuI_Uo/hqdefault.jpg" width="480" height="360"/>
<media:description>Description 1.</media:description>
<media:community>
<media:starRating count="1" average="5.00" min="1" max="5"/>
<media:statistics views="13"/>
</media:community>
</media:group>
</entry>
<entry>
<id>yt:video:uhAXp6sdfsddRnSA</id>
<yt:videoId>uhAXp6sdfsdRnSA</yt:videoId>
<yt:channelId>MyChannel</yt:channelId>
<title>
Title 2
</title>
<link rel="alternate" href="https://www.youtube.com/watch?v=uhAXsdsdp6dRnSA"/>
<author>
<name>Jon Smith</name>
<uri>
https://www.youtube.com/channel/MyChannel
</uri>
</author>
<published>2014-10-28T21:39:27+00:00</published>
<updated>2017-07-26T17:42:27+00:00</updated>
<media:group>
<media:title>
Title 2
</media:title>
<media:content url="https://www.youtube.com/v/uhAXp6dRnsddSA?version=3" type="application/x-shockwave-flash" width="640" height="390"/>
<media:thumbnail url="https://i2.ytimg.com/vi/uhAXp6dsdsdRnSA/hqdefault.jpg" width="480" height="360"/>
<media:description>Description 2</media:description>
<media:community>
<media:starRating count="0" average="0.00" min="1" max="5"/>
<media:statistics views="25"/>
</media:community>
</media:group>
</entry>
</feed>
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="feed">
<html>
<body>
<h2>My Videos</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th style="text-align:left">Title</th>
<th style="text-align:left">Image URL</th>
</tr>
<xsl:for-each select="entry">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="media:thumbnail/@url"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
正要具有完全相同的回答,但与非'的'! –
Parfait