简体   繁体   English

在Codeigniter中使用xml-string-streamer

[英]Using xml-string-streamer with Codeigniter

Is it possible to use a library such as the xml string streamer ( https://github.com/prewk/xml-string-streamer ) in Codeigniter? 是否可以在Codeigniter中使用诸如xml字符串流媒体( https://github.com/prewk/xml-string-streamer )之类的库? It utilises namespaces which Codeigniter doesn't recognise. 它利用了Codeigniter无法识别的名称空间。

I'm currently using: 我目前正在使用:

require_once 'application/libraries/XmlStringStreamer.php';

use application\libraries\XmlStringStreamer;

However, I now get: 但是,我现在得到:

Parse error: syntax error, unexpected T_USE

To clarify, I need to request 9 2mb+ sized xml streams, parse them, compare the data in each and output where there are discrepancies as quickly as possible (aiming for ~5 seconds at most). 为了清楚起见,我需要请求9个2mb +大小的xml流,对其进行解析,比较每个流中的数据,并输出存在差异的尽快(最多约5秒)。 This is my last try, as the structure of the XML files is similar to: 这是我的最后一次尝试,因为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>

With upto 600 competition elements in each stream, numerous attributes in each element, and all elements needed except lineups, lineups_bench, substitutions, penalty_shootout, goals, bookings and extra, so if you have any other suggestions that would be helpful. 每个流中最多包含600个比赛元素,每个元素中都有许多属性,除了阵容,lineups_bench,替补,刑罚,目标,预订等外,还需要所有其他元素,因此,如果您有其他建议会有所帮助。 When we were comparing much fewer competitions, I was using XMLReader to pull out and parse the Competition block, then converting each competition element into a SimpleXML object, but with 600 competitions, I need to find a way of reducing how much I'm downloading. 当我们比较少得多的竞赛时,我使用XMLReader提取并解析了Competition块,然后将每个竞赛元素转换为SimpleXML对象,但是对于600个竞赛,我需要找到一种减少下载量的方法。

The more I look at it, the more I think this XML isn't fit for the task, so this is my last try before requesting a change to the API generating the XML or I'll try to stream smaller datasets somehow. 我看的越多,我就越认为此XML不适合该任务,因此这是我在请求更改生成XML的API之前的最后尝试,否则我将尝试以某种方式流式传输较小的数据集。

Please check your PHP version as if it support the usage of this line : 请检查您的PHP版本,是否支持此行的用法:

use application\libraries\XmlStringStreamer;

if not , just upgrade your php version to the latest one. 如果没有,只需将您的php版本升级到最新版本。 have a nice day :) 祝你今天愉快 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM