Reply to Re: split large xml files

Your name:

Reply:


Posted by gosha bine on 08/10/07 11:32

On 10.08.2007 11:21 David Gillen wrote:
> Bob Bedford said:
>> Hi all,
>>
>> I've an XML file that takes more than the hosting time limit to be readed by
>> a PHP script.
>>
>> What I'd like to do is split the large XML file (can be more than 30MB) in
>> little parts and keep the header for every file.
>>
>> Here is the idea:
>>
>> <total>
>> <head>
>> </head>
>> <info>
>> </info>
>> <info>
>> </info>
>> <info>
>> </info>
>> ...
>> </total>
>>
>> The only change is the amount of "info" available. What I'd like is to split
>> the file to create littles ones whit the same <head></head> datas but each
>> with less <info> tags (say limited to 3 for every file).
>>
>> It's there any simple way ? This will only be done if the file is bigger
>> than 1MB
>>
> $xml = simplexml_load_file($xmlFile);
> And take it from there. Have a quick read of the simplexml docs. You should
> have your solution in very little time.
>


Didn't test it, but I doubt simplexml would be able to load a 30MB xml
file. I think OP's best option is to use the tool that can read and
parse in small chunks, like expat (see
http://www.php.net/manual/en/function.xml-parse.php)


--
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация