Ads by Google
Posted by ellen at September 04, 2007 04:26 PM
<xsl:value-of select="../excerpt" disable-output-escaping="yes"/&rt;Example of xml which contains HTML data:
Example of XSL fragment which displays the data:
<?xml version="1.0" encoding="UTF-8"?>
<blog_entries>
<blog_entry id="0">
<date>09/01/2007</date>
<title>Entry Title</title>
<excerpt>
<![CDATA[
This is an excerpt that contains some HTML data. <a href="http://google.com" target="_blank">testing URL's in cdata section</a>
]]>
</excerpt>
<text>This is the rest of the article and contains some HTML code</text>
<author>Author name</author>
</blog_entry>
<blog_entry id="1">
<date>09/01/2007</date>
<title>Entry Title 2</title>
<excerpt>
<![CDATA[
Short excerpt here.<a href="http://google.com" target="_blank">testing URL's in cdata section</a>
]]>
</excerpt>
<text>
<![CDATA[ Longer excerpt here<a href="http://google.com" target="_blank">testing URL's in cdata section</a> ]]>
</text>
<author>another author</author>
</blog_entry>
</blog_entries>
----<?xml version="1.0" encoding="UTF-8"?>
<!-- DWXMLSource="blog.xml" -->
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "™">
<!ENTITY mdash "—">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="html" encoding="UTF-8"/>
<xsl:template match="/">
<style type="text/css">
<xsl:comment>
.blogText{font:11px Verdana, Arial, Helvetica;}</xsl:comment>
</style><xsl:for-each select="blog_entries/blog_entry/date">
<div align="left" class="blogText">
<xsl:value-of select="."/><br />
<b><xsl:value-of select="../title"/></b><br />
<xsl:value-of select="../excerpt" disable-output-escaping="yes"/><br />
<xsl:value-of select="../text" disable-output-escaping="yes"/><br />
<xsl:value-of select="../author"/>
</div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Ads by Google