Answer the question
In order to leave comments, you need to log in
Slow XML parsing using PHP. How to increase speed?
There is a task to parse xml files from vimeo video hosting. Implementation script:
<?php
function vimeo_parse($video_id) {
$url = "http://vimeo.com/api/v2/video/".$video_id.".xml";
$xml = simplexml_load_file($url);
$vimeo_title = $xml->video->title;
$vimeo_thumb = $xml->video->thumbnail_large;
return array($vimeo_title,$vimeo_thumb,$video_id);
}
// пример использования
// list ($vimeo_title,$vimeo_thumb,$vimeo_id) = vimeo_parse("27973852");
// echo $vimeo_title;
// echo $vimeo_thumb;
// echo $vimeo_id;
?>
Answer the question
In order to leave comments, you need to log in
LIBXML_COMPACT?
And, in general, the problem, it seems, is an architectural plan. If the files are small, then the time is mostly spent downloading via HTTP. Download 20 files, put on disk and compare the performance. If confirmed, only some clever pre-caching will help.
Are you polling the server, and why should it be faster? Cache poll results, load asynchronously via js on the client.
Create a background script that will download data to you.
For large XML 10mb-2gb use XmlReader to bypass the nodes to read the SimpelXMl node.
Polling the server constantly is not an option, sooner or later it will not be able to give you XML, you will show the visitor not what he wanted to see and he will leave the site
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question