Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > PHP: X технологии > Warning: SimpleXMLElement


Автор: Fubu_By 22.1.2010, 17:54
вот строка которая глючит:
Код

$this->xml = new SimpleXMLElement($this->path, NULL, true);


вот именно тот xml файл на котором вылетело:
Код

http://sandbox.api.shopping.com/publisher/3.0/rest/GeneralSearch?apiKey=6d6523e9-bc3e-4de4-b43a-9b33676367ad&trackingId=8058284&categoryId=68185&showProductSpecs=true&numItems=100&pageNumber=7


вот ошибка:
Код

http://sandbox.api.shopping.com/publisher/3.0/rest/GeneralSearch?apiKey=6d6523e9-bc3e-4de4-b43a-9b33676367ad&trackingId=8058284&categoryId=68185&showProductSpecs=true&numItems=100&pageNumber=7

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: http://sandbox.api.shopping.com/publisher/3.0/rest/GeneralSearch?apiKey=6d6523e9-bc3e-4de4-b43a-9b33676367ad&trackingId=8058284&categoryId=68185&showProductSpecs=true&numItems=100&pageNumber=7:1: parser error : Premature end of data in tag sourceURL line 1 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: "400"><sourceURL>http://di1.shopping.com/images/pi/7b/d6/51/51035686-400x400-0-0 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: http://sandbox.api.shopping.com/publisher/3.0/rest/GeneralSearch?apiKey=6d6523e9-bc3e-4de4-b43a-9b33676367ad&trackingId=8058284&categoryId=68185&showProductSpecs=true&numItems=100&pageNumber=7:1: parser error : Premature end of data in tag image line 1 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: "400"><sourceURL>http://di1.shopping.com/images/pi/7b/d6/51/51035686-400x400-0-0 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: http://sandbox.api.shopping.com/publisher/3.0/rest/GeneralSearch?apiKey=6d6523e9-bc3e-4de4-b43a-9b33676367ad&trackingId=8058284&categoryId=68185&showProductSpecs=true&numItems=100&pageNumber=7:1: parser error : Premature end of data in tag images line 1 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: "400"><sourceURL>http://di1.shopping.com/images/pi/7b/d6/51/51035686-400x400-0-0 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: http://sandbox.api.shopping.com/publisher/3.0/rest/GeneralSearch?apiKey=6d6523e9-bc3e-4de4-b43a-9b33676367ad&trackingId=8058284&categoryId=68185&showProductSpecs=true&numItems=100&pageNumber=7:1: parser error : Premature end of data in tag product line 1 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: "400"><sourceURL>http://di1.shopping.com/images/pi/7b/d6/51/51035686-400x400-0-0 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: http://sandbox.api.shopping.com/publisher/3.0/rest/GeneralSearch?apiKey=6d6523e9-bc3e-4de4-b43a-9b33676367ad&trackingId=8058284&categoryId=68185&showProductSpecs=true&numItems=100&pageNumber=7:1: parser error : Premature end of data in tag items line 1 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: "400"><sourceURL>http://di1.shopping.com/images/pi/7b/d6/51/51035686-400x400-0-0 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: http://sandbox.api.shopping.com/publisher/3.0/rest/GeneralSearch?apiKey=6d6523e9-bc3e-4de4-b43a-9b33676367ad&trackingId=8058284&categoryId=68185&showProductSpecs=true&numItems=100&pageNumber=7:1: parser error : Premature end of data in tag category line 1 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: "400"><sourceURL>http://di1.shopping.com/images/pi/7b/d6/51/51035686-400x400-0-0 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: http://sandbox.api.shopping.com/publisher/3.0/rest/GeneralSearch?apiKey=6d6523e9-bc3e-4de4-b43a-9b33676367ad&trackingId=8058284&categoryId=68185&showProductSpecs=true&numItems=100&pageNumber=7:1: parser error : Premature end of data in tag categories line 1 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: "400"><sourceURL>http://di1.shopping.com/images/pi/7b/d6/51/51035686-400x400-0-0 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: http://sandbox.api.shopping.com/publisher/3.0/rest/GeneralSearch?apiKey=6d6523e9-bc3e-4de4-b43a-9b33676367ad&trackingId=8058284&categoryId=68185&showProductSpecs=true&numItems=100&pageNumber=7:1: parser error : Premature end of data in tag GeneralSearchResponse line 1 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: "400"><sourceURL>http://di1.shopping.com/images/pi/7b/d6/51/51035686-400x400-0-0 in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\WebServers\home\idooble\www\include\classes\CXML.php:32 Stack trace: #0 C:\WebServers\home\idooble\www\include\classes\CXML.php(32): SimpleXMLElement->__construct('http://sandbox....', 0, true) #1 C:\WebServers\home\idooble\www\include\classes\CXML.php(93): CXML->GetXML() #2 C:\WebServers\home\idooble\www\include\classes\CXML.php(94): CXML->ParseProducts('Luggage') #3 C:\WebServers\home\idooble\www\include\classes\CXML.php(94): CXML->ParseProducts('Luggage') #4 C:\WebServers\home\idooble\www\include\classes\CXML.php(94): CXML->ParseProducts('Luggage') #5 C:\WebServers\home\idooble\www\include\classes\CXML.php(94): CXML->ParseProducts('Luggage') #6 C:\WebServers\home\idooble\www\include\classes\CXML.php(94): CXML->ParseProducts('Luggage') #7 C:\WebServers\home\idooble\www\include\classes\CXML.php(60): CXML->ParseProducts('Luggage') #8 C:\WebServers\home\idooble\www\include\classes\CXML.php(53): CXML->FindCategory(Object(Simpl in C:\WebServers\home\idooble\www\include\classes\CXML.php on line 32



перед этим было создано достаточно много таких объектов, может это изза переполнения какого-нибудь, если да тот как бороться с этим?

Автор: skyboy 22.1.2010, 20:07
ты пытаешься обработать xml, который механизм парсинга считает некорректным. 
раз это происходит "от случая к случаю", то, очевидно, проблема в данных, а не в структуре. например, среди текста появляется "<" не конвертированный в "&lt;"

Автор: Fubu_By 23.1.2010, 12:03
ну еслибы были ошибки в синтаксисе самого xml, то при открытии в бреузере, думаю, браузер вывалил ошибку, а так всё ок.

Автор: sTa1kEr 23.1.2010, 13:51
Нужно сначала скачать XML при помощи сокетов или cURL и только затем парсить его.

Автор: Fubu_By 23.1.2010, 16:12
Цитата(sTa1kEr @ 23.1.2010,  13:51)
Нужно сначала скачать XML при помощи сокетов или cURL и только затем парсить его.

а смысл? можно подробнее для чего сохранять его в файле?

Автор: sTa1kEr 23.1.2010, 16:37
Сохранять его в файл не нужно, SimpleXMLElement::__construct() первым параметром принимает так же строку с XML. 
А смысл в том, что бы отделить мух от котлет. Т.к. ошибка скачивания файла и ошибка парсинга XML - это две совершенно разные ошибки.
И в случае ошибок в синтаксисе смотреть нужно тот XML, который у вас скачался через скрипт, а не тот, что отображается в браузере.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)