从天气预报中我将这个元素放在XSLT片段中:
<xsl:value-of select="data/current_condition/weatherCode"/>
这会返回一个数字,例如122
我有另一个XML列出了天气代码的详细信息,例如:
<condition>
<code>122</code>
<description>Overcast</description>
<day_icon>wsymbol_0004_black_low_cloud</day_icon>
<night_icon>wsymbol_0004_black_low_cloud</night_icon>
</condition>
<condition>
<code>119</code>
<description>Cloudy</description>
<day_icon>wsymbol_0003_white_cloud</day_icon>
<night_icon>wsymbol_0004_black_low_cloud</night_icon>
</condition>
那我该如何动态获取,例如代码122的描述,图标等?
答案 0 :(得分:1)
<xsl:variable name="weather_desc" select="document('2.xml')/root"/>
<xsl:variable name="weather_code" select="data/current_condition/weatherCode"/>
<xsl:value-of select="$weather_desc/condition[code=$weather_code]/description"/>