So I have some code here that loops through an xml file. Here is the xml file.
[code=html]<?xml version=”1.0″?>
<events>
<event>
<startDateTime>2013-06-28T00:31:00Z</startDateTime>
<id>309893600</id>
<IsLive>Yes</IsLive>
<status>O</status>
<drawRotNum>25</drawRotNum>
<homeTeam type=”Team1″>
<name>AC Milan</name>
<rotNum>23</rotNum>
<score>1</score>
</homeTeam>
<awayTeam type=”Team2″>
<name>AS Roma</name>
<rotNum>24</rotNum>
<score>2</score>
</awayTeam>
<periods>
<period lineId=”103648769″>
<number>0</number>
<description>Game</description>
<cutoffDateTime>2013-06-28T00:31:00Z</cutoffDateTime>
<spreads>
<spread>
<awaySpread>1</awaySpread>
<awayPrice>105</awayPrice>
<homeSpread>-1</homeSpread>
<homePrice>-115</homePrice>
</spread>
<spread altLineId=”186287960″>
<awaySpread>1.25</awaySpread>
<awayPrice>-121</awayPrice>
<homeSpread>-1.25</homeSpread>
<homePrice>110</homePrice>
</spread>
</spreads>
<totals>
<total>
<points>1</points>
<overPrice>-105</overPrice>
<underPrice>-105</underPrice>
</total>
<total altLineId=”186287961″>
<points>0.75</points>
<overPrice>110</overPrice>
<underPrice>-124</underPrice>
</total>
</totals>
<moneyLine>
<awayPrice>112</awayPrice>
<homePrice>121</homePrice>
<drawPrice>131</drawPrice>
</moneyLine>
<teamTotals>
<homeTeamTotal>
<total>1</total>
<overPrice>-105</overPrice>
<underPrice>-105</underPrice>
</homeTeamTotal>
<awayTeamTotal>
<total>2</total>
<overPrice>-105</overPrice>
<underPrice>-105</underPrice>
</awayTeamTotal>
</teamTotals>
<maxBetAmount>
<spread>4000</spread>
<totalPoints>4000</totalPoints>
<moneyLine>2000</moneyLine>
<teamTotals>5000</teamTotals>
</maxBetAmount>
</period>
</periods>
</event>
</events>
Here is the php file that processes the xml:
[code=php] <?php
$xml = simplexml_load_file(“xml2.xml”);
foreach ($xml->event as $feed) { ?>
<h1> <?php echo $feed->status; ?> </h1>
<?php } ?>
The code above works correctly as $feed->status correctly outputs “Yes” but when I try something $feed->rotNum or $feed->rotNum[‘1’] nothing is outputted. I can’t seem to figure out what the problem is. Can someone help me out with this?