XSL : Problème pour visualiser le contenu de <content>
Hello,
J'associe un XSL à un RSS, mais j'ai un problème d'affichage.
Voici le XML:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:content="http://purl.org/rss/1.0/modules/content/" >
<channel>
<item>
<title>title 1</title>
<content:encoded>
<![CDATA[this is <b>a test</b>]]>
</content:encoded>
</item>
<item>
<title>title 2</title>
<content:encoded>
<![CDATA[this is <b>a test</b>]]>
</content:encoded>
</item>
</channel> |
Voici le XSL :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html><head><title>test</title></head>
<body>
<xsl:for-each select="rss/channel/item">
<xsl:value-of select="title"/><br />
<xsl:value-of select="content"/><br />
</xsl:for-each>
</body></html>
</xsl:template>
</xsl:stylesheet> |
Tout marche, sauf que je ne vois pas le contenu de la balise <content:encoded>.
Si j'écris <xsl:value-of select="content:encoded"/> dans le fichier XSL, ca me cree une erreur. Je ne sais pas quoi faire.
Re: XSL : Problème pour visualiser le contenu de <content
Bonjour,
content est le préfixe de l'espace de nom "http://purl.org/rss/1.0/modules/content/". Il faut que tu déclares cet espace de nom dans ton XSL, pour qu'il le reconnaisse :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<xsl:output method="html"/>
<xsl:template match="/">
<html><head><title>test</title></head>
<body>
<xsl:for-each select="rss/channel/item">
<xsl:value-of select="title"/><br />
<xsl:value-of select="content:encoded"/><br />
</xsl:for-each>
</body></html>
</xsl:template>
</xsl:stylesheet> |