V
V
Vlad Nesterenko2020-03-03 18:53:11
Laravel
Vlad Nesterenko, 2020-03-03 18:53:11

Gives out of memory error XMLReader::XML?

Good afternoon, does it give an error about lack of memory? I declare two variables $xmlReader = new XMLReader() and I get an error Warning: XMLReader::XML(): Memory allocation failed : growing buffer
A piece of the program where I declare variables

$mas_xml= file_get_contents('Price.xml');
  $xmlReader = new XMLReader();
  $xmlReader->xml($mas_xml);
    while ( $xmlReader->read() &&  $xmlReader->name !== 'categories');
    $node = new SimpleXMLElement($xmlReader->readOuterXML());

 $mas_xml2=file_get_contents('GoodsProperties.xml');
$xmlReader_descriptions = new XMLReader();
 $xmlReader_descriptions->xml($mas_xml2);
 while ( $xmlReader_descriptions->read() &&  $xmlReader_descriptions->name !== 'properties');

 $node_descriptions = new SimpleXMLElement($xmlReader_descriptions->readOuterXML());

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nokimaro, 2020-03-03
@Vlad852

Increase the memory limit for the script, for example up to 2GB

<?php
ini_set("memory_limit", "2056M"); //выделяем 2Гб памяти на работу скрипта

Or learn how to parse XML streaming. Successfully thus parsed XML on 50Gb in the size.
https://drib.tech/programming/parse-large-xml-files-php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question