Load complete XML with simplexml_load_string

0

I have an XML that has a parent node Produtos and 2500 child nodes produto , all child nodes have a id key that starts at 1 and goes up to 2500. When I try to load XML using the simplexml_load_string function only 2237 child nodes are "parseted", is there any limit to this function? If so, how can I increase? below code used;

$call = curl_init();

$options = [
    CURLOPT_URL             => $import->xml_path,
    CURLOPT_RETURNTRANSFER  => 1,
    CURLOPT_SSL_VERIFYPEER  => false,
    CURLOPT_CUSTOMREQUEST   => 'GET',
    CURLOPT_CONNECTTIMEOUT  => 20,
    CURLOPT_RETURNTRANSFER  => 1,
    CURLOPT_SSL_VERIFYHOST  => 0,
];

$xml = simplexml_load_string($xmlString, null, LIBXML_NOCDATA);
// => $xml é uma classe SimpleXMLElement com um attributo 'produto' (array) com 2238 indices.
    
asked by anonymous 08.03.2018 / 17:23

1 answer

0

As of version 2.7.3 of libxml, the simplexml_load_string function can receive only a maximum of 10MB per call.

According to:

  

Since version 2.7.3 libxml limits the maximum size of a single text   node to 10MB. The limit can be removed with a new option,   XML_PARSE_HUGE. PHP has no way to specify this option to libxml.

You can use XML_PARSE_HUGE to work around this limitation, since you can not set it straight to libxml.

References:

XML_PARSE_HUGE on function simplexml_load_string ()

PHP bug report

    
08.03.2018 / 17:48