Last.fm 活动场地查询
我目前正在构建一个应用程序来返回所选城市的演出,例如使用last.fm geo.getEvents API 的爱丁堡。
进展顺利,但我想将每场演出都归类到各自的演出场地下。例如,
VENUE 1: eventname1, eventname2
VENUE 2: eventname5, eventname7
etc.
我尝试编写一个嵌套循环来获取场地,然后获取相关的演出,但我失败了。这是我将使用的来自last.fm 的XML(示例)。
<events location="New York" page="1" totalpages="105" total="1050">
<event>
<id>640418</id>
<title>Nikka Costa</title>
<artists>
<artist>Nikka Costa</artist>
<headliner>Nikka Costa</headliner>
</artists>
<venue>
<name>Bowery Ballroom</name>
看来嵌套循环不起作用,因为演出/艺术家名称不在层次结构中的“场地”标签下方。
关于如何做到这一点有什么想法吗?谢谢。
I'm currently building an application to return gigs in the selected city, e.g. Edinburgh using the last.fm geo.getEvents API.
It's going well, but I'd like to categorise each gig under its respective gig venue. e.g.
VENUE 1: eventname1, eventname2
VENUE 2: eventname5, eventname7
etc.
I tried coding a nested loop grab the venues then the associated gigs, but I failed with that. Here is the XML (sample) I'll be working with from last.fm.
<events location="New York" page="1" totalpages="105" total="1050">
<event>
<id>640418</id>
<title>Nikka Costa</title>
<artists>
<artist>Nikka Costa</artist>
<headliner>Nikka Costa</headliner>
</artists>
<venue>
<name>Bowery Ballroom</name>
It appears that the nested loop didn't work as the gig/artist name is not below the 'venue' tag in the hierarchy.
Any ideas of how to do this? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 API 不允许场地返回结果,您可能必须手动执行此操作。您可以创建一个多维数组。
$events['Bowery Ballroom'][640418];
它可以按场地索引,然后按事件索引。您可以按如下方式添加到数组中:
$events['venue_name'][] = 1234; // 其中 1234 是事件 ID
You might have to manually do this if the API does not allow for results to be returned by venue. You could create a multi-dimensional array.
$events['Bowery Ballroom'][640418];
It could be indexed by venue and then by event. You could add to the array as follows:
$events['venue_name'][] = 1234; // where 1234 is the event ID