使用 simpleXML 解析 foursquare KML 场地提要
我正在尝试使用 simpleXML 解析来自 foursqare 的 KML 场地提要,但我无法获取嵌套在描述中的场地 url。看起来 simpleXML 剥离了它。
详细信息:
foursqare kml feed 看起来像这样:
<kml>
<Folder>
<name>foursquare checkin history for X</name>
<description>foursquare checkin history for X</description>
<Placemark>
<name>somevenuename</name>
<description>@<a href="/v/somevenueurl">somevenuename</a>- a foursqareshout!</description>
<updated>Wed, 02 Nov 11 17:00:05 +0000</updated>
<published>Wed, 02 Nov 11 17:00:05 +0000</published>
<visibility>1</visibility>
<Point>
<extrude>1</extrude>
<altitudeMode>relativeToGround</altitudeMode>
<coordinates>xx.xxxxxx,yy.yyyyyy</coordinates>
</Point>
</Placemark>
etc ...
我对 simpleXMl 的调用是......嗯,简单:$venue_items = simplexml_load_file($venue_kml_file);
有什么想法谁可以在 description
中保留 html 吗?
I am trying to parse a KML venue feed from foursqare with simpleXML but I cannot get the nested-in-desctription venue url. It looks like simpleXML strips it.
In detail:
The foursqare kml feed looks like this:
<kml>
<Folder>
<name>foursquare checkin history for X</name>
<description>foursquare checkin history for X</description>
<Placemark>
<name>somevenuename</name>
<description>@<a href="/v/somevenueurl">somevenuename</a>- a foursqareshout!</description>
<updated>Wed, 02 Nov 11 17:00:05 +0000</updated>
<published>Wed, 02 Nov 11 17:00:05 +0000</published>
<visibility>1</visibility>
<Point>
<extrude>1</extrude>
<altitudeMode>relativeToGround</altitudeMode>
<coordinates>xx.xxxxxx,yy.yyyyyy</coordinates>
</Point>
</Placemark>
etc ...
My call to simpleXMl is ... well, simple:$venue_items = simplexml_load_file($venue_kml_file);
Any ideas who to preserve the html in description
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
他们是对的。这是无效的 XML。不过,我使用正则表达式为您编写了一个解决方法。这可能有点hacky,但你只能用你所得到的来偿还,所以这里是:
希望有帮助......
They're right. This is invalid XML. However, I wrote a workaround for you using regex. It may be a bit hacky, but you can only make due with what you've been given, so here it is:
Hope that helps...