您好我正试图从节点
中的文本中提取部分句子The xml:
<coast>
<area>
Forecast for coasts from Malin Head to Howth Head to Roches Point and the Irish Sea
</area>
<wind>Northwest force 6 to gale force 8 and gusty, decreasing force 5 to 7 this morning. Increasing early tonight northwest force 7 to gale force 8.</wind>
</coast>
<all-wx><head>Weather for all sea areas:</head>
<text>
Scattered showers, some will be wintry.</text>
</all-wx>
<all-vis><head>Visibility for all sea areas:</head>
<text>
Poor in any showers.Warning of heavy swell: along Atlantic coasts.</text>
</all-vis>
<outlook time="0600" day="Sunday" date="01 February 2015">
<head>Outlook for a further 24 hours until 0600 Sunday 01 February 2015: </head>
<text> Gale force to strong gale force northerly winds with further showers, some will be thundery.</text>
</outlook>
<gale-text>
Northwest winds will reach gale force for a time this morning on all Irish coastal waters and on the Irish Sea </gale-text>
<craft-text>
NIL </craft-text>
The xsl:
<xsl:template match="coast">
<p>
<h4><xsl:value-of select="area"/></h4>
<p><strong>Wind: </strong>
<xsl:value-of select="wind"/>
</p>
<xsl:if test="weather">
<p>
<strong>Weather: </strong>
<xsl:value-of select="weather"/>
</p>
</xsl:if>
<xsl:if test="visibility">
<p>
<strong>Visibility: </strong>
<xsl:value-of select="visibility"/>
</p>
<p>
<xsl:template match="text">
<xsl:value-of select="substring-after(., 'Warning of heavy swell:')"/>
</xsl:template>
</p>
</xsl:if>
</p>
</xsl:template>
我希望将文字提取到重度膨胀警告的右侧:并显示在网页上
以上不起作用。
非常新手编码器 - 任何帮助表示赞赏。
由于
答案 0 :(得分:0)
如果您使用
<xsl:template match="text">
<xsl:value-of select="substring-after(., 'Warning of heavy swell:')"/>
<xsl:template>
然后您会在Warning of heavy swell:
元素中获得text
后面的字符串。