I'm trying to print out this xml from a API.
<XMLSOCCER.COM>
<Match>
<Id>309389</Id>
<Date>2013-08-04T16:00:00+02:00</Date>
<League>Scottish Premier League</League>
<Round>1</Round>
<HomeTeam>St Johnstone</HomeTeam>
<HomeTeam_Id>46</HomeTeam_Id>
<HomeGoals>1</HomeGoals>
<AwayTeam>Hearts</AwayTeam>
<AwayTeam_Id>50</AwayTeam_Id>
<AwayGoals>0</AwayGoals>
<Time>Finished</Time>
<Location>McDiarmid Park</Location>
<HomeTeamYellowCardDetails>83': Murray Davidson;</HomeTeamYellowCardDetails>
<AwayTeamYellowCardDetails>78': Jamie Hamill;</AwayTeamYellowCardDetails>
<HomeTeamRedCardDetails/>
<AwayTeamRedCardDetails/>
</Match>
<Match>
<Id>309390</Id>
<Date>2013-08-03T16:00:00+02:00</Date>
<League>Scottish Premier League</League>
<Round>1</Round>
<HomeTeam>Aberdeen</HomeTeam>
<HomeTeam_Id>45</HomeTeam_Id>
<HomeGoals>2</HomeGoals>
<AwayTeam>Kilmarnock</AwayTeam>
<AwayTeam_Id>52</AwayTeam_Id>
<AwayGoals>1</AwayGoals>
<Time>Finished</Time>
<Location>Pittodrie Stadium</Location>
<HomeTeamYellowCardDetails>39': Jonathan Hayes;</HomeTeamYellowCardDetails>
<AwayTeamYellowCardDetails>38': James Fowler;18': Christopher Johnston;</AwayTeamYellowCardDetails>
<HomeTeamRedCardDetails/>
<AwayTeamRedCardDetails/>
</Match>
</XMLSOCCER.COM>
and here is my PHP code I have written so far:
foreach($response->Match as $match){
print "{$match->HomeTeam}<br />\n";
}
print $response -> {"XMLSOCCER.COM"};
But I can't seem to get any output, I keep getting errors such as:
- Undefined property: stdClass::
- Trying to get property of non-object in
I'm just wondering if anyone could point me in the right direction with this. At the moment I'd just to like print out a HomeTeam name for example, from here I can progress further.