Reputation: 1952
I am trying to transform the feed of bank of canada to use it in my app.
Here is my xml and my xsl: http://xsltransform.net/bFDb2D4/4
I can't change the xml, this is a rss feed. The only line that blocks me is this one:
xmlns="http://purl.org/rss/1.0/"
If I delete this one, my selector is good and I get the result. I am a beginner in xslt. Can someone explain me what I did wrong ?
Upvotes: 0
Views: 111
Reputation: 32990
The
xmlns="http://purl.org/rss/1.0/"
says that all unqualified element names like RDF, item, title in the XML have the given namespace. In order to match these elements you need the same namespace definition in your XSLT and inclue the namespace prefix in your XPath expressions:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rss="http://purl.org/rss/1.0/"
exclude-result-prefixes = "rss">
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:apply-templates select="/rss:RDF/rss:item"/>
</xsl:template>
<xsl:template match="rss:item">
<p>
<xsl:value-of select="rss:title"/><br/>
<xsl:value-of disable-output-escaping="yes" select="description"/>
</p>
</xsl:template>
</xsl:stylesheet>
Upvotes: 1