Hallo,
Wie komme ich da nun z.B. an den Wert von "Humidity" ran?
Das klappt irgendwie nicht:
<xsl:value-of select="content:encoded/dl/dd[@id='humidity']"/>an Content:encoded komme ich ran, kann aber nicht mehr tiefer gehen
Der Inhalt von content:encoded ist ein CDATA-Abschnitt, der fuer XPath nicht direkt zugaenglich ist. Man kann nur den gesamten Textknoten abfragen und muss dann Zeichenkettenfunktionen anwenden. Vom Ansatz her funktioniert es so:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
exclude-result-prefixes="content">
<xsl:output
method="html"
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
doctype-system="http://www.w3.org/TR/html401/loose.dtd"
encoding="ISO-8859-1"
version="4.01"/>
<xsl:template match="/">
<html>
<head>
<title>RSS-Weather-Test</title>
</head>
<body>
xsl:apply-templates/
</body>
</html>
</xsl:template>
<xsl:template match="/rss/channel">
<xsl:apply-templates select="item//content:encoded"/>
</xsl:template>
<xsl:template match="content:encoded">
<xsl:variable name="temp" select="substring-after(text(),'id="humidity" style="display: inline;">')"/>
<xsl:variable name="humidity" select="substring-before($temp,'</dd>')"/>
<p>Humidity: <xsl:value-of select="$humidity"/></p>
</xsl:template>
</xsl:stylesheet>
Ergebnis:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>RSS-Weather-Test</title>
</head>
<body><p>Humidity: 55%</p></body>
</html>
MfG, Thomas