You've tried to extend the script's maximum execution time with set_time_limit()? This will not cause the server to crash (because it has a memory limit too):
set_time_limit( 0 ); // No time limit is imposed
I'm not sure what you mean with "breaking down" the script, you might want to have a second thought on that.
What you could do if there are to many rows in the feed's XML you also could make your own import script and take care of its handle your own way by processing small part by small part.
$xml_handler = new ProductsParser();
$xml_parser = xml_parser_create();
$source = '--URL--';
xml_set_object( $xml_parser, $xml_handler );
xml_parser_set_option( $xml_parser, XML_OPTION_CASE_FOLDING, false );
xml_set_element_handler( $xml_parser, 'startElement', 'endElement' );
xml_set_character_data_handler( $xml_parser, 'cdata' );
$fp = fopen ( $source, 'r' );
while ( $chunk = fread( $fp, 4096 ) ) {
xml_parse( $xml_parser, $chunk, feof( $fp ) );
flush();
}
fclose( $fp );
class ProductsParser {
public $product; # Holds the record values
public $elem_key; # Holds the current element key while reading
public $record; # Holds the record tag
function __construct( $args ) {
$this->product = false;
$this->elem_key = false;
$this->record = '--RECORD-NAME--';
}
function startElement( $parser, $tag, $attributes ) {
if ( $this->record == $tag && ! is_array( $this->product ) ) {
$this->product = array();
} elseif( is_array( $this->product ) ) {
$this->elem_key = $tag;
}
}
function endElement( $parser, $tag ) {
if ( $this->record == $tag && is_array( $this->product ) ) {
// Process the product row
$this->product = false;
} elseif ( is_array( $this->product ) && $this->elem_key != false ) {
$this->elem_key = false;
}
}
function cdata( $parser, $cdata ) {
if ( is_array( $this->product ) && $this->elem_key != false ) {
$this->product[$this->elem_key] = $cdata;
}
}
}
More information about the XML parser can be found in the PHP manual.