Using a DOM parser, the whole XML document is loading in memory -- which can lead to problems when working with a big document (I know, you probably don't have much of a choice)
First of all, I would try not to open the same document more than once :
- it means more work for PHP : it has to parse a big document several times, and, each time, build the DOM tree in memory
- it might require more memory -- In theory, when leaving the function in which you instanciated the
DOMDocument
object, its destructor should be called, and memory released, but, who knows...
About the "Is the above the old style of loading a document", well, looking at the documentation for DOMDocument::load
, it seems it can be called both dynamically (see the example) and statically (see the return value section) ; so, I suppose both solutions are OK, and there is no "old way" nor "new way".
What do you mean by "my script just ends abruptly" ? Do you have a Fatal Error about memory_limit
?
If yes, if you can change that kind of configuration setting, it might help to set memory_limit
to a higher value.