如何用 PHP 解析 NOAA 天气警报 CAP?
您好,
我在理解如何用 PHP 解析 NOAA 的天气警报 CAP 时遇到了一些困难。我需要执行以下操作:
- 在源中找到正确的县
- 验证是否存在活动警报
- 显示警报的描述
我正在使用的源位于此地址 - http://www.weather.gov/alerts/va.cap 我过去曾使用 simplexml_load_string()
来处理此类事情,但它似乎不适用于此提要。
谢谢!
Greetings,
I am having some difficulty understanding how to parse NOAA's Weather Alert CAP in PHP. I need to do the following:
- Locate the proper county in the feed
- Verify that there is an active alert
- Display the alert's description
The feed I am working with is at this address - http://www.weather.gov/alerts/va.cap
I have used simplexml_load_string()
in the past for this sort of thing but it does not seem to work for this feed.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在谷歌上呆了一段时间后,我发现了一个脚本,它完全符合我想要做的事情。我不会尝试重新发明轮子,而是会顺其自然。 http://saratoga-weather.org/scripts-atom.php#atomadvisory
After some more time on Google I came across a script that does exactly what I am trying to do. Rather than try to reinvent the wheel, I am going to go with it. http://saratoga-weather.org/scripts-atom.php#atomadvisory
您可能会因命名空间而遇到问题。
这应该会让您了解如何提取信息
顺便说一下,SimpleXml 仅适用于简单的 XML。考虑使用 DOM 代替。
You are probably having an issue due to the namespace
This should give you an idea of how to extract information
On a sidenote, SimpleXml is for simple XML only. Consider using DOM instead.