Forum Moderators: coopster

Message Too Old, No Replies

Reading a big(25 mb) xml-file line by line with php

how to? having troubles with file and fgets.

         

ikbenhet1

8:31 pm on Sep 22, 2003 (gmt 0)

10+ Year Member



Hi, i have a 25mb xml-file that contains my county's part of the DMOZ.
i tried to use file(); and also fgets(); to read it but the tags seem to dissapear, all i get is text and descriptions, i need the rest too.

I want to read this text file, so i can use preg_match to insert the data into a mysql database.
Any ideas how to read this file line by line, without losing "data".
Thanks.

jatar_k

8:42 pm on Sep 22, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Since it's xml have you tried these?

PHP XML parser functions [ca.php.net]

You would think there would be dmoz data parsing scripts available. Have you tried some searches for premade scripts?

ikbenhet1

8:59 pm on Sep 22, 2003 (gmt 0)

10+ Year Member




yes, i tried suckdmoz but i couldnt get it to work.

This is probably not a valid xml file since i took only a part out of the middle of the dump, there is no header...

If i could only read it line by line i could insert it all into a db. Is there a way to read it line by line?
Thanks in advance.

bluedevil

11:20 pm on Sep 22, 2003 (gmt 0)

10+ Year Member



Try using fread()

I'm using it for some 100+ Mb XML-files so it should work.

vincevincevince

9:09 am on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



are you sure the tags are disappearing? try echoing <plaintext> before echoing your data when you test if the tags are there...

ikbenhet1

2:04 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



VinceVinceVince, <Plaintext> works! Thank you, i have alread inputted the data it into the db.
My previous reply got lost in a 404 i think, since it's not here.