Hey All,
I am pretty new to simpleXML and have a decent grasp of PHP but I cant seem to get a file I want to parse in PHP fully.
I can get it to render the first level which are the divisions, but I cant get it to render the "children" which are the teams and the stats that are part of the teams level. You can load the php at http://www.nyriptide.com/test/a_standing.php The code has the raw XML data below what is already parsed. This is basically a standings table that is for my collegiate teams website.
Can anyone help me with the sublevels
My PHP file is below and so is the Remote Data tree:
<?php
$file = 'http://www.pointstreak.com/baseball/api/index.php?action=league_standings&seasonid=158&leagueid=152';
$xmlstr = file_get_contents($file);
$xml = new SimpleXMLElement($xmlstr);
echo '<h1>Table of xml stuff formatted</h1>';
echo '<p>League Name: ' . $xml->leaguename[0] . '</p>';
echo '<p>League ID: ' . $xml->attributes()->leagueid[0] . '</p>';
echo '<table border="1" width="100%" id="table1" cellpadding="8" style="border-collapse: collapse" bordercolor="#FF0000">';
foreach($xml->divisions->division as $div){
echo '<tr><td>';
echo '<p>Div Name: ' . $div->attributes()->name[0] . '</p>';
echo '</td></tr>';
}
echo '</table>';
echo '<h1>XML Raw</h1>';
echo '<pre>';
print_r($xml);
echo '</pre>';
?>
<league leagueid="152">
<leaguename>New York City Metro Baseball League A</leaguename>
−
<season seasonid="158">
<seasonname>Summer 2010</seasonname>
<link>standings.html?leagueid=152%26;seasonid=158</link>
</season>
−
<divisions>
+
<division name="Bk/Qns - Brooklyn">
<teams>
</teams>
</division>
−
<division name="Bk/Qns - Queens East">
−
<teams>
−
<team id="3155">
<teamname>NY/LI Rough Riders</teamname>
<shortname>Riders</shortname>
<games>0</games>
<wins>0</wins>
<losses>0</losses>
<ties>0</ties>
<rs>0.0</rs>
<ra>0.0</ra>
<rdiff>0</rdiff>
<pct>0.000</pct>
<gb/>
<streak>-</streak>
<last10>0-0</last10>
</team>
−
<team id="3156">
<teamname>Queens Royals</teamname>
<shortname>Royals</shortname>
<games>0</games>
<wins>0</wins>
<losses>0</losses>
<ties>0</ties>
<rs>0.0</rs>
<ra>0.0</ra>
<rdiff>0</rdiff>
<pct>0.000</pct>
<gb/>
<streak>-</streak>
<last10>0-0</last10>
</team>
−
<team id="3154">
<teamname>Elmjack Blue Jays</teamname>
<shortname>Blue Jays</shortname>
<games>0</games>
<wins>0</wins>
<losses>0</losses>
<ties>0</ties>
<rs>0.0</rs>
<ra>0.0</ra>
<rdiff>0</rdiff>
<pct>0.000</pct>
<gb/>
<streak>-</streak>
<last10>0-0</last10>
</team>
</teams>
</division>
−
<division name="Bk/Qns - Queens West">
<teams>
</teams>
</division>
−
<division name="Bx/Man - Bronx">
<teams>
</teams>
</division>
−
<division name="Bx/Man - Manhattan Downtown">
<teams>
</teams>
</division>
−
<division name="Bx/Man - Manhattan Uptown">
<teams>
</teams>
</division>
</divisions>
</league>