xml parsing - Multiple XML Query Issues -


for project working on need query 1 xml url , retrieve list of players using predetermined franchise id. player ids need query second xml url , retrieve player names , teams, display in list.

here's i'm trying do:

first query

url: http://football99.myfantasyleague.com/2007/export?type=rosters&l=46184

  • i need select each player id listed under predetermined franchise id.

second query

url: http://football.myfantasyleague.com/2013/export?type=players&players=3291

  • here need able retrieve player name , team using player id retrieved specific franchise id, in first query.

after of have results of second query show in list.

this means first query 15 player ids retrieved , player ids need figure out way each individual player name , team.

would willing me out here? can provide more information if ask.

// parse , display $data=array();  $url1 = "http://football99.myfantasyleague.com/2007/export?type=rosters&l=46184"; $xml = simplexml_load_file($url1);  foreach($xml->franchise->player $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 player names , teams using player ids above */ $url2 = "http://football.myfantasyleague.com/2013/export?type=players&players=3291"; $xml_second = simplexml_load_file($url2);  foreach($xml_second->players->player $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/>'; } 

results

warning: invalid argument supplied 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 

this did trick.

$year         = '2007'; $league       = '46184'; $franchise_id = '0001';  // parse , display $data=array();  // players each franchise $url = 'http://football99.myfantasyleague.com/'.$year.'/export?type=rosters&l='.$league.'&franchise='.$franchise_id.''; $xml = simplexml_load_file($url);  foreach($xml->franchise->player $franchise_two) {   $player_id=(string) $franchise_two->attributes()->id;    $data[$player_id]['playerid']=(string) $franchise_two->attributes()->id;      // create list of player ids     $player_list = ''.$data[$player_id]['playerid'].',';       // parse players      $players = simplexml_load_file('http://football.myfantasyleague.com/2013/export?type=players&players='.$player_list.'');       foreach ($players $player):        $player_name=$player['name'];       endforeach;         // display output        while(list($key,$franchise)=each($data)) {         $list .= 'franchise id: '.$franchise_id.'<br/>player id: '.$franchise['playerid'].'<br/>player name: '.$player_name.'<br/><br/>';        } }  echo ''.$list.''; 

echo result

franchise id: 0001

player id: 8025

player name: anderson, derek

etc...


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -