Hi,
I am using XSLT to style a XML data. The data includes pictures which are presented this way:
PHP Code:
<weatherIconUrl>
<![CDATA[
http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png
]]>
</weatherIconUrl>
Using only PHP, things work well, but the pictures come one under another one. While the purpose is to have them next to each other.
With php to show a picture the way the XML source gives it goes like this:
PHP Code:
$picture=$item->weatherIconUrl;
$line = preg_replace('#<!\[CDATA\[.*?\]\]>#s', '', $picture);
echo "<img src='$line' /> <br />";
The PHP XSLT combination work some other way. I wonder which way?
The working PHP code is:
PHP Code:
<html><head></head>
<body>
<?php
$xslDoc = new DOMDocument();
$xslDoc->load("filename.xsl"); //Here comes to XSL file name
$xmlDoc = new DOMDocument();
$xmlDoc->load("http://free.worldweatheronline.com/feed/weather.ashx?q=milan,italy&format=xml&num_of_days=5&key=af8b2fc417222733111712");
$proc = new XSLTProcessor();
$proc->importStylesheet($xslDoc);
echo $proc->transformToXML($xmlDoc);
?>
</body>
</html>
The working XSL code is:
PHP 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>
<td>
<p><xsl:value-of select="weather[1]/date"/> </p>
<p><xsl:value-of select="weather[1]/weatherIconUrl"/></p>
<hr />
</td>
<td>
<p><xsl:value-of select="weather[2]/date"/> </p>
<p><xsl:value-of select="weather[2]/weatherIconUrl"/></p>
<hr />
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
This bit of code shows the picture URLs but not the pictures. How to get the pictures visible?