RCB
RCB

Reputation: 99

XML to HTML Conversion & Display

How Can I display the below XML into an HTML page: http://weather.maltairport.com/xml/WeatherReport_21032014.xml

XML Sample:

<WeatherForecast>
<date>2014-03-21</date>
<publishedtime>17:00:14</publishedtime>
<forecast>
<time>16:40</time>
<forecastvalid>Outlook for Tomorrow</forecastvalid>
<conditiontoday>SUNNY</conditiontoday>
<temperature>16</temperature>
<humidity>76</humidity>
<atmospressure>1021</atmospressure>
<wind>SE 8 Knots</wind>
<sunrise>06:05</sunrise>
<forecastimage>
http://weather.maltairport.com/assets/img-design/weatherconditions/52.png
</forecastimage>
<sunset>18:14</sunset>
<dayforecast day="1">
<forecastdate>2014-03-22</forecastdate>
<condition>MAINLY CLOUDY</condition>
<high>17</high>
<low>12</low>
<heat_stress>17</heat_stress>
<wind_direction>ESE</wind_direction>
<wind_force>F3 --> SSE F3 to 4</wind_force>
<uvindex>5</uvindex>
<forecastimage>
http://weather.maltairport.com/assets/img-design/weatherconditions/21.png
</forecastimage>
</dayforecast>

I am a newbie to these types of XML files so any help/guidance is truly appreciated.

Upvotes: 0

Views: 86

Answers (1)

Stuart Kershaw
Stuart Kershaw

Reputation: 17671

You need a couple things:

A) An XSL file that transforms the XML into an output type of your choice, in this case HTML.

B) A PHP (or other) script to merge and process the transform. I use the following script in a project of mine:

<?php
$xml = new DOMDocument;
$xml->load('index.xml');

$xsl = new DOMDocument;
$xsl->load('index.xsl');

$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);

echo $proc->transformToXML($xml);
?>

Upvotes: 1

Related Questions