使用带Codeigniter的xml字符串流


Using xml-string-streamer with Codeigniter

是否可以使用诸如xml字符串拖缆(https://github.com/prewk/xml-string-streamer)?它使用Codeigniter无法识别的名称空间。

我目前正在使用:

require_once 'application/libraries/XmlStringStreamer.php';
use application'libraries'XmlStringStreamer;

然而,我现在得到:

Parse error: syntax error, unexpected T_USE

为了澄清,我需要请求9个2mb+大小的xml流,解析它们,比较每个流中的数据,并尽快输出有差异的地方(最多5秒)。这是我的最后一次尝试,因为XML文件的结构类似于:

<competition>
 <season>
  <round>
   <match>
    <matchinfo>
     <venue/>
     <referee/>
     <assistant_referee/>
     <assistant_referee/>
     <fourth_official/>
     <attendance/>
     <coach_team_a/>
     <coach_team_b/>
    </matchinfo>
    <lineups/>
    <lineups_bench/>
    <substitutions/>
    <penalty_shootout/>
    <goals/>
    <bookings/>
    <extra/>
   </match>
  </round>
 </season>
</competition>

每个流中有多达600个比赛元素,每个元素中有许多属性,以及除阵容、阵容替补、换人、点球大战、进球、预订和额外外所需的所有元素,所以如果你有任何其他有用的建议。当我们比较更少的竞争时,我使用XMLReader提取并解析Competition块,然后将每个竞争元素转换为SimpleXML对象,但对于600个竞争,我需要找到一种减少下载量的方法。

我看得越多,就越觉得这个XML不适合这个任务,所以这是我在请求更改生成XML的API之前的最后一次尝试,否则我将尝试以某种方式流式传输较小的数据集。

请检查您的PHP版本是否支持使用以下行:

use application'libraries'XmlStringStreamer;

如果没有,只需将php版本升级到最新版本即可。度过美好的一天:)