1

Good day!

I have a PHP script that reads a very huge XML file. I used fgets to read line by line. In some point, we need to stop the said script to check some data integrity. My problem is how to resume that running state (I mean the line which the script stopped). We don't want to start the script all over again for it takes days to be completed.

Is there such way that I can accomplish this? Any suggestion would be greatly appreciated.

acidpaul
  • 165
  • 2
  • 14

2 Answers2

0

DomDocument ?

Philip
  • 4,592
  • 2
  • 20
  • 28
  • Sorry but I haven't used DomDocument before. I'll try to search on this and see how it works. Thanks for the quick response. – acidpaul Apr 29 '12 at 04:47
0

There's also SimpleXML library of PHP which needs to be installed before using it in your applications, but before you use any of it's functions, it loads all of the XML document into it's cache.

There's also XMLReader library, which is used to read XML files without loading all of the file to cache, and is the better method for using for situations like this.

Here you can find information about these two libraries :

http://us.php.net/manual/en/book.xmlreader.php

http://us.php.net/manual/en/book.simplexml.php

And examples of using them:

http://us.php.net/manual/en/simplexml.examples-basic.php

And here's much more detailed explanation :

How to use XMLReader in PHP?

Community
  • 1
  • 1
Taha Paksu
  • 15,371
  • 2
  • 44
  • 78