Convert xml to html

Hi,

I’m using dreamweaver to pull in a Wordpress RSS Feed onto my web page. I can’t figure out how to make it render proper HTML. In the Description Field it pulls out all of the <p> tags in the feed and displays some unknow characters instead.

Here’s my code:


<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="http://blogs.fortlewis.edu/sponsoredresearch/feed/" -->
<!DOCTYPE xsl:stylesheet  [
 <!ENTITY nbsp   "&#160;">
 <!ENTITY copy   "&#169;">
 <!ENTITY reg    "&#174;">
 <!ENTITY trade  "&#8482;">
 <!ENTITY mdash  "&#8212;">
 <!ENTITY ldquo  "&#8220;">
 <!ENTITY rdquo  "&#8221;"> 
 <!ENTITY pound  "&#163;">
 <!ENTITY yen    "&#165;">
 <!ENTITY euro   "&#8364;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<xsl:output method="html" encoding="utf-8"/>
<xsl:param name="ItemsPerPage" select="3" />
<xsl:template match="/">
  <xsl:for-each select="rss/channel/item">
    <p><a href="{link}"><strong><xsl:value-of select="title"/></strong></a><br />
      <xsl:value-of select="description" disable-output-escaping="yes"/></p>
  </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Here’s the output:

http://www.fortlewis.edu/test/sponsoredresearch/news.asp

Can someone point me in the right direction?

Hello,

You may want to try adding the following doctypes to your xsl:output:


<xsl:output 
    method="html" 
    encoding="UTF-8" 
    indent="yes" 
    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" 
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
/>

I am currently using a CMS at my job (OmniUpdate) that makes heavy use of XML/XSL templates. Whenever I’ve had weird character problems, it always seems to be a DTD issue.

Hope this helps, or at least puts you on the right track!

Hi,

Thanks for the reply. I have played with the doctype a little but haven’t had any luck yet. Maybe I need to use a different script than the one Dreamweaver is using?

-s

Ah sorry, I didn’t see that xsl bit in there. Not sure what else to suggest, I’m afraid.

Hi, I have tried that in the XSL document but all it does is print out the XSL code on my page. As far as I can tell there is a CDATA tag around that field in the feed that is coming in so that should do it but it doesn’t.

The only thing that has come close is using Server.HTMLEncode() to convert the special characters to HTML but that sitll doesn’t display <em>, <strong> and other tags.

I spent all day yesterday looking for an answer but I haven’t found anything.

Thanks for the reply.

-s

I’m no expert at this (far from it!) but to get HTML to work in RSS feeds I wrap it in CDATA tags, as shown in red:

[COLOR="Red"]<![CDATA[[/COLOR]    <p><a href="{link}"><strong><xsl:value-of select="title"/></strong></a><br />   [COLOR="Red"]]]>[/COLOR]

See if that helps. :slight_smile: