如何在HTML页面中显示以下XML:http://weather.maltairport.com/xml/WeatherReport_21032014.xml
XML示例:
<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>
我是这些类型的XML文件的新手,因此真正感谢任何帮助/指导。
答案 0 :(得分:1)
你需要做几件事:
A)XSL
文件,用于将XML
转换为您选择的输出类型,在本例中为HTML
。
B)用于合并和处理转换的PHP
(或其他)脚本。我在我的一个项目中使用以下脚本:
<?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);
?>