View Single Post
Old 12-29-2011, 09:13 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
These aren't images, they are only text. You need to put them in an img tag in order to have them parsed by HTML as an image.
You don't need to use the preg replace at all here. CDATA blocks are an XML indicator for textual data that will not be parsed by the XML processor. Images are a bit of a pain in xsl, so I'll break this down as smaller template matches:
Code:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="weathertest.xsl"?>
<data>
	<weather>
		<date>Today</date>
<weatherIconUrl>
<![CDATA[
http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png
]]>
</weatherIconUrl>
	</weather>
	<weather>
		<date>Tomorrow</date>
<weatherIconUrl>
<![CDATA[
http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png
]]>
</weatherIconUrl>
	</weather>
</data>
Data above assumed on the xslt you have.

My weathertest.xsl:
Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="data">
    <table>
        <tr>
            <xsl:apply-templates />
        </tr>
    </table>
</xsl:template>

<xsl:template match="weather">
    <td>
        <p><xsl:value-of select="./date" /></p>
        <p><xsl:apply-templates select="./weatherIconUrl" /></p>
    </td>
</xsl:template>

<xsl:template match="weatherIconUrl">
    <img>
        <xsl:attribute name="src">
            <xsl:value-of select="." />
        </xsl:attribute>
    </img>
</xsl:template>
</xsl:stylesheet>
And all done. I didn't bother with PHP in this case, but its results should be the same.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
JonesJ (12-30-2011)