0
對於我正在處理的項目,我需要查詢一個XML URL並檢索使用預定特許經營編號的玩家列表。使用這些玩家ID,我需要查詢第二個XML URL並檢索玩家名稱和團隊,然後將其顯示在列表中。多個XML查詢問題
這裏就是我想要做的事:
首先查詢
網址:http://football99.myfantasyleague.com/2007/export?TYPE=rosters&L=46184
- 我需要選擇在預定專營ID下的每個玩家ID。
第二個查詢
網址:http://football.myfantasyleague.com/2013/export?TYPE=players&PLAYERS=3291
- 在這裏,我需要能夠使用我們從具體的專營ID檢索到的玩家ID檢索球員的名字和團隊,在第一個查詢。
畢竟,我希望第二個查詢的結果顯示在列表中。
這意味着從第一個查詢中可以找到類似15個玩家id的東西,並且通過這些玩家ID我需要找出一種方法來獲取每個玩家的名字和團隊。
難道有人願意幫助我嗎?如果你問,我可以提供更多信息。
// Parse and display
$data=array();
$url1 = "http://football99.myfantasyleague.com/2007/export?TYPE=rosters&L=46184";
$xml = simplexml_load_file($url1);
foreach($xml->franchise->player as $franchise_one) {
$id=(string) $franchise_one->attributes()->id;
$data[$id]['id']=(string) $franchise_one->attributes()->id;
$data[$id]['playerid']=(string) $franchise_one->attributes()->id;
}
/* Query list to get player names and teams using the player ids from above */
$url2 = "http://football.myfantasyleague.com/2013/export?TYPE=players&PLAYERS=3291";
$xml_second = simplexml_load_file($url2);
foreach($xml_second->players->player as $player) {
$id=(string) $player->attributes()->id;
$data[$id]['name']=(string) $player->attributes()->name;
}
while(list($key,$franchise)=each($data)) {
$list .= 'Franchise id: '.$franchise['id'].'<br/>Player id: '.$franchise['playerid'].'<br/>Player name: '.$player['name'].'<br/><br/>';
}
結果
Warning: Invalid argument supplied for foreach() in --- on line 41
Franchise id: 8025
Player id: 8025
Player name: l
Franchise id: 7394
Player id: 7394
Player name: l
Franchise id: 6780
Player id: 6780
Player name: l
Franchise id: 7740
Player id: 7740
Player name: l
Franchise id: 5004
Player id: 5004
Player name: l
Franchise id: 5656
Player id: 5656
Player name: l
Franchise id: 4914
Player id: 4914
Player name: l
Franchise id: 6562
Player id: 6562
Player name: l
Franchise id: 7403
Player id: 7403
Player name: l
Franchise id: 7393
Player id: 7393
Player name: l
Franchise id: 8266
Player id: 8266
Player name: l
Franchise id: 6528
Player id: 6528
Player name: l
Franchise id: 7653
Player id: 7653
Player name: l
Franchise id: 6952
Player id: 6952
Player name: l
Franchise id: 8339
Player id: 8339
Player name: l
Franchise id: 8074
Player id: 8074
Player name: l
Franchise id: 0521
Player id: 0521
Player name: l