Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SimpleXML parser error: "Huge input lookup"

Tags:

php

simplexml

I am using PHP for the first time. I am getting the following error on running the PHP file:

PHP Warning:  simplexml_load_string(): Entity: line 35909: parser error : internal error: Huge input lookup in /home/alisverispasaji/public_html/system/xml/minikoli/test.php on line 8

PHP Warning:  simplexml_load_string(): p;lt;img src="/UserFiles/FCK/image/prima hangisi(1).jpg" class in /home/alisverispasaji/public_html/system/xml/minikoli/test.php on line 8

PHP Warning:  simplexml_load_string():                                                                                ^ in /home/alisverispasaji/public_html/system/xml/minikoli/test.php on line 8

PHP Fatal error:  Call to a member function children() on boolean in /home/alisverispasaji/public_html/system/xml/minikoli/test.php on line 20

How I can solve this error?

test.php:

<?php
ini_set('user_agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20100101 Firefox/9.0');
error_reporting(-1);

function simplexml_load_file_curl($url) {
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $xml = simplexml_load_string(curl_exec($ch)); // <--- line 8
    return $xml;
}

$url = 'xml link';

$xml = simplexml_load_file_curl($url);

$veri = '<?xml version="1.0" encoding="UTF-8"?>';
$veri .= '
<Urunler>';

foreach($xml->children() as $urun) { // <--- line 20
like image 436
Ümit BÜKÇÜOĞLU Avatar asked Mar 31 '17 06:03

Ümit BÜKÇÜOĞLU


1 Answers

Problem Solved

Find ;

$xml = simplexml_load_string(curl_exec($ch));

Change ;

$xml = simplexml_load_string(curl_exec($ch), 'SimpleXMLElement', LIBXML_COMPACT | LIBXML_PARSEHUGE);
like image 73
Ümit BÜKÇÜOĞLU Avatar answered Oct 05 '22 14:10

Ümit BÜKÇÜOĞLU