我需要实现一个 PHP 文件来从一个目录中读取 x 个文件,并且每次更新我的数据库中的一个表。更新没问题,但是,我不是 php 中最好的 xml。所以,这是 xml 文件:
<SeasonStatistics competition_name="Italian Serie A" season_name="Season 2015/2016" season_id="2015" competition_id="21">
<Team name="Roma" id="121"><Stat name="Total Shots">102</Stat>
<Stat name="Possession Percentage">64</Stat><Stat name="Total Fouls Won">93</Stat>
<Stat name="Unsuccessful Dribbles">60</Stat>
<Stat name="PutThrough/Blocked Distribution">125</Stat>
<Stat name="Goals">17</Stat>
<Stat name="Headed Goals">2</Stat>
<Stat name="Unsuccessful lay-offs">5</Stat>
<Stat name="Total Passes">3868</Stat><Stat name="Crossing Accuracy">21.55</Stat>
<Stat name="Throw Ins to Opposition Player">12</Stat>
<Stat name="Total Unsuccessful Passes ( Excl Crosses & Corners )">543</Stat>
<Stat name="Shots On Conceded Inside Box">21</Stat>
<Stat name="Throw Ins to Own Player">127</Stat>
<Stat name="Shots On Target ( inc goals )">50</Stat>
<Stat name="Clean Sheets">1</Stat>
<Player position="Defender" player_id="61021" shirtNumber="5" known_name="Leandro Castán" last_name="Castan da Silva" first_name="Leandro">
<Stat name="Time Played">90</Stat>
<Stat name="Successful Launches">1</Stat>
<Stat name="Open Play Passes">42</Stat>
<Stat name="Backward Passes">1</Stat>
</Player>
</Team>
</SeasonStatistics>
所以,我的目录中有 x 个文件,我需要阅读所有文件。当我阅读我想要的文件时:
-$array($teamname -----> $position ->$statval)
-$array2($playerstat ----> $position ----->$statval)
我怎样才能做到这一点?当第一个 xml 文件完成时,我如何解析下一个?
感谢所有 Matteo