从XML到HTML的XSLT输出
我有这样的XML从XML到HTML的XSLT输出,xml,xslt,Xml,Xslt,我有这样的XML <item> <title>Fastfood</title> <description><![CDATA[<p> <b> For more info, visit us </b><a href ="www.website.com">www.website.com</a></p> ]]></description> <lin
<item>
<title>Fastfood</title>
<description><![CDATA[<p>
<b> For more info, visit us </b><a href ="www.website.com">www.website.com</a></p>
]]></description>
<link>http://www.website.com/</link>
<author>TCPC</author>
<guid isPermaLink="false">a57c770b-a85d-437f-aceb-fd0fc3a0bfb2</guid>
<pubDate>Mon, 25 Nov 2013 15:39:48 GMT</pubDate>
<enclosure url="http://www.website.com/images/logo.jpg" type="image/jpeg" length="16645" />
</item>
<xsl:for-each select="rss/channel/item">
<xsl:if test="position() <= 10"> <!--Displays only 10 entries-->
<div style="background-color:#a61f2e;color:white;padding:4px; padding-left:1em;">
<span style="font-weight:bold; font-size: 1.5em;">
<a id ="{author}"></a>
<xsl:value-of select="title"/>
</span>
</div>
<div style="margin-left:20px;margin-bottom:1em; margin-right:1em;">
<br></br>
<h6 style="font-style:italic">
<xsl:value-of select="pubDate"/>
</h6>
<br></br>
<span style ="font: normal 14px/1.5 'Segoe UI'">
<xsl:value-of select="description" />
</span>
<br></br>
</div>
</xsl:if>
</xsl:for-each>
<br></br>
<hr></hr>
</html>
快餐
欲了解更多信息,请访问我们
<xsl:for-each select="rss/channel/item">
<xsl:if test="position() <= 10"> <!--Displays only 10 entries-->
<div style="background-color:#a61f2e;color:white;padding:4px; padding-left:1em;">
<span style="font-weight:bold; font-size: 1.5em;">
<a id ="{author}"></a>
<xsl:value-of select="title"/>
</span>
</div>
<div style="margin-left:20px;margin-bottom:1em; margin-right:1em;">
<br></br>
<h6 style="font-style:italic">
<xsl:value-of select="pubDate"/>
</h6>
<br></br>
<span style ="font: normal 14px/1.5 'Segoe UI'">
<xsl:value-of select="description" />
</span>
<br></br>
</div>
</xsl:if>
</xsl:for-each>
<br></br>
<hr></hr>
</html>
]]>
http://www.website.com/
<xsl:for-each select="rss/channel/item">
<xsl:if test="position() <= 10"> <!--Displays only 10 entries-->
<div style="background-color:#a61f2e;color:white;padding:4px; padding-left:1em;">
<span style="font-weight:bold; font-size: 1.5em;">
<a id ="{author}"></a>
<xsl:value-of select="title"/>
</span>
</div>
<div style="margin-left:20px;margin-bottom:1em; margin-right:1em;">
<br></br>
<h6 style="font-style:italic">
<xsl:value-of select="pubDate"/>
</h6>
<br></br>
<span style ="font: normal 14px/1.5 'Segoe UI'">
<xsl:value-of select="description" />
</span>
<br></br>
</div>
</xsl:if>
</xsl:for-each>
<br></br>
<hr></hr>
</html>
您应该更改
<xsl:for-each select="rss/channel/item">
<xsl:if test="position() <= 10"> <!--Displays only 10 entries-->
<div style="background-color:#a61f2e;color:white;padding:4px; padding-left:1em;">
<span style="font-weight:bold; font-size: 1.5em;">
<a id ="{author}"></a>
<xsl:value-of select="title"/>
</span>
</div>
<div style="margin-left:20px;margin-bottom:1em; margin-right:1em;">
<br></br>
<h6 style="font-style:italic">
<xsl:value-of select="pubDate"/>
</h6>
<br></br>
<span style ="font: normal 14px/1.5 'Segoe UI'">
<xsl:value-of select="description" />
</span>
<br></br>
</div>
</xsl:if>
</xsl:for-each>
<br></br>
<hr></hr>
</html>
<span style ="font: normal 14px/1.5 'Segoe UI'">
<xsl:value-of select="description" />
</span>>
>
到
<xsl:for-each select="rss/channel/item">
<xsl:if test="position() <= 10"> <!--Displays only 10 entries-->
<div style="background-color:#a61f2e;color:white;padding:4px; padding-left:1em;">
<span style="font-weight:bold; font-size: 1.5em;">
<a id ="{author}"></a>
<xsl:value-of select="title"/>
</span>
</div>
<div style="margin-left:20px;margin-bottom:1em; margin-right:1em;">
<br></br>
<h6 style="font-style:italic">
<xsl:value-of select="pubDate"/>
</h6>
<br></br>
<span style ="font: normal 14px/1.5 'Segoe UI'">
<xsl:value-of select="description" />
</span>
<br></br>
</div>
</xsl:if>
</xsl:for-each>
<br></br>
<hr></hr>
</html>
您可以将禁用输出转义=“yes”
添加到
元素中。也就是说,将
元素放在
中看起来不是一个好主意,您可能应该使用
来代替。可能的重复项我无法控制XML文件。谢谢,这很有效