【发布时间】:2015-03-08 08:54:32
【问题描述】:
我有一个来自 url 的数据点 xml,最后有我的 api 密钥 所以它不会以 .xml 结尾,而是以数字结尾。
我上周一直在尝试理解 xml,但我感到困惑 当有多个 id 时,理想情况下我希望下面的 xml 在 php 中显示 当用作包含时,我看过 Simple XML,但我再次很容易感到困惑:/
我也试过这个,希望它能做我想要的,顺便说一句,我已经搜索过了 通过很多这样的小脚本
<?php
// The file test.xml contains an XML document with a root element
// and at least an element /[root]/title.
if (file_exists('metoforecast.xml')) {
$xml = simplexml_load_file('metoforecast.xml');
print_r($xml);
} else {
exit('Failed to open metoforecast.xml.');
}
?>
我通过使用程序抓取 xml 进行编辑,并使用 .xml 文件名和 上传到我的网站,就像我说的,我很困惑:(
我希望它看起来像这样
一些明亮或阳光明媚的咒语,然后在下午下雨。
今天: 一些明亮或阳光充足的时期,特别是在该地区的东部,但下午有更多的云和零星的降雨向东蔓延。最高温度 12C。
今晚: 任何降雨都会很快清除,给一个干燥的夜晚带来一些清晰的咒语和一些地方的霜冻,尽管到早晨云量往往会再次增加。最低温度0C。
星期一: 干燥开始后,加厚的云层稍后会从西部带来一些零星的降雨。然而,下午东部可能会出现一些更明亮的咒语。最高温度 11C。
周二至周四的展望: 周二有一些阳光明媚的咒语干燥。周三的早霜随后干燥而明亮,但到了晚上西部会下雨。周四部分地区还会下雨。
英国未来 5 天的预报 今日东南云雨晴。明天多雨多风。 今天: 起初,苏格兰和北爱尔兰有阳光明媚的咒语和零星的阵雨,天气凉爽。其他地方经常多云,威尔士和英格兰西北部的早期降雨缓慢地向东南方向蔓延并逐渐减弱。西北风逐渐减弱,天气变得干燥、明亮。
今晚: 一个大部分干燥的夜晚,伴随着漫长而清晰的咒语和微风,使霜冻形成。遥远的西部越来越多云,有大雨,黎明时分强风。
星期一: 从东方开始明亮但寒冷。北方和西北地区变得潮湿多风,有强风的风险。微风轻拂,南部有更多零星降雨。
周二至周四的展望: 周二开始寒冷,随后天气晴朗干燥。周三和周四变得更加不安,有时会下雨,还有一些强风。
2015 年 3 月 12 日星期四至 2015 年 3 月 21 日星期六的英国展望: 由于锋面系统向东穿过英国,周四的大部分地区可能会受到一些降雨影响。西部有时会下大雨,也可能有强风。东部地区的降雨可能会持续到周五,但随着预计会形成高压,情况应该会变得更加稳定。这在英国留下了很多干燥的天气,有一些明亮或阳光明媚的咒语,尽管很可能有大量的云和主要是小雨或毛毛雨的奇怪点。这种情况似乎会持续到接下来的一周。尽管仍有可能出现一些寒冷的夜晚,但风通常应该是微弱的,温度接近一年中的平均水平。
2015 年 3 月 22 日星期日至 2015 年 4 月 5 日星期日的英国展望: 随着我们进入 3 月下旬到 4 月,高压很可能会逐渐减弱。这意味着北部地区可能会变得更加不稳定,有阵雨或更长的降雨期。然而,在更南的地方,看起来条件将保持比平均水平更干燥,春天的阳光更多。每天的温度变化可能相当大,白天温暖,夜晚寒冷。
更新于:2015 年 3 月 8 日星期日 0252
<RegionalFcst xmlns="www.metoffice.gov.uk/xml/metoRegionalFcst" createdOn="2015-03-07T15:10:53" issuedAt="2015-03-07T16:00:00" regionId="ee">
<FcstPeriods>
<Period id="day1to2">
<Paragraph title="Headline:">Dry with increasing cloud. Mild although breezy.</Paragraph>
<Paragraph title="This Evening and Tonight:">
After a fine evening and clear start to the night cloud will thicken after midnight, though most parts will stay dry. Breezy winds will continue overnight. Minimum Temperature 5C.
</Paragraph>
<Paragraph title="Sunday:">
Generally cloudy with periods of rain and some brighter spells during the afternoon. Winds should ease and western parts may see a bright evening. Maximum Temperature 12C.
</Paragraph>
</Period>
<Period id="day3to5">
<Paragraph title="Outlook for Monday to Wednesday:">
Monday, a bright start but becoming windy with a spell of rain later. Tuesday should be fine with light winds. Wednesday starting fine but cloud thickening and wind strengthening later.
</Paragraph>
</Period>
<Period id="day6to15">
<Paragraph title="UK Outlook for Thursday 12 Mar 2015 to Saturday 21 Mar 2015:">
It is likely that some rain will affect most parts on Thursday as a frontal system tracks its way eastwards across the UK. The rain may be heavy at times in the west with strong winds also possible. The rain may linger in the east into Friday but things should then turn more settled as high pressure is expected to develop. This leaves a lot of dry weather over the UK with some bright or sunny spells though there may well be large amounts of cloud and the odd spot of mostly light rain or drizzle. This situation looks to persist into the following week. Winds should be generally light with temperatures close to average for the time of year, although some cold nights are still likely.
</Paragraph>
</Period>
<Period id="day16to30">
<Paragraph title="UK Outlook for Sunday 22 Mar 2015 to Sunday 5 Apr 2015:">
It is most probably that there will be a gradual weakening of the high pressure as we head through the latter part of March and into April. This means northern parts could well turn more unsettled, with showers or perhaps longer spells of rain. However, further south it looks like conditions are set to remain drier than average, with more spring sunshine. There is likely to be quite a large daily variation in temperatures, with warm days but chilly nights.
</Paragraph>
</Period>
</FcstPeriods>
</RegionalFcst>
希望你的
腼腆
【问题讨论】: