В настоящее время у меня проблема с импортом большого XML-файла, и я не могу понять, почему. Мы получаем вывод XML от партнера размером около 443 МБ. Ошибка, которую я получаю, выглядит следующим образом:
PHP Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : internal error in /home/imports/catalog.php on line 54
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : internal error in /home/imports/catalog.php on line 54
PHP Warning: SimpleXMLElement::__construct(): ch to marriage, parenting, entrepreneurship, etc will be significantly upgraded. in /home/imports/catalog.php on line 54
Warning: SimpleXMLElement::__construct(): ch to marriage, parenting, entrepreneurship, etc will be significantly upgraded. in /home/imports/catalog.php on line 54
PHP Warning: SimpleXMLElement::__construct():
^ in /home/imports/catalog.php on line 54
Warning: SimpleXMLElement::__construct():
^ in /home/imports/catalog.php on line 54
PHP Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/imports/catalog.php:54
Stack trace:
#0 /home/imports/catalog.php(54): SimpleXMLElement->__construct('<?xml version="...')
#1 {main}
thrown in /home/imports/catalog.php on line 54
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/imports/catalog.php:54
Stack trace:
#0 /home/imports/catalog.php(54): SimpleXMLElement->__construct('<?xml version="...')
#1 {main}
thrown in /home/imports/catalog.php on line 54
Строка 54 кода проста:
$xml = new SimpleXMLElement(file_get_contents($_CFG_XML_URL));
Насколько я могу судить, ошибка в элементе, содержащем ch to marriage, parenting, entrepreneurship, etc will be significantly upgraded.. К сожалению, это длинный путь к файлу, и из-за его размера трудно прочитать содержимое. Моя программа для чтения больших файлов читает построчно, а весь этот XML находится в одной строке, так что это слишком сложно для корректной обработки даже на рабочей станции с 32 ГБ ОЗУ и 64-разрядным редактором.
Я пытался перезагрузить файл несколько раз, но проблема всегда одна и та же. Я удвоил доступную память для сценария, и он все еще не работает в том же месте.
Итак, я связался с партнером и попросил XML для этого конкретного элемента, и они предоставили следующее:
<EBook EAN="9792219192201">
<Title>Success-a-Phobia</Title>
<SubTitle>Discovering And Conquering Mankinds Most Persuasive, but Unknown, Phobia</SubTitle>
<Publisher>The Benjamin Consulting Group, LLC</Publisher>
<PublicationDate>29/09/2012</PublicationDate>
<Contributors>
<Contributor Code="A01" Text="By (author)">Benjamin, Marcus D.</Contributor>
</Contributors>
<Formats>
<Format Type="6"/>
</Formats>
<ShortDescription>People today still desire to be successful in matters of family, finance or business even though we are in the midst of major social, political and economic challenges. Have you every been at that moment where you wanted to do something significant, yet you were paralyzed from making the necessary choices to realize your dream? Have you experienced failure and are now sitting in the stands, paralyzed from getting back in the &quote;game of life?&quote; Are you at the verge of a major decision that could affect your life for many years? If you are in this category, this is your book of the year! With humor, real-life antidotes, real-life examples and solid narration, Marcus Benjamin will guide you toward discovering the most pervasive, yet unknown, phobia in the history of mankind. Once this phobia is discovered, the second half of the book shows you how to rid yourself of this phobia for good. Not only will this book impact your life, but your approach to marriage, parenting, entrepreneurship, etc will be significantly upgraded.</ShortDescription>
</EBook>
Ничто в этом XML не тревожит меня, но явно на полпути к PHP возникла проблема. Похоже, что в содержимом элемента содержится 978 символов, но это не вызывает у меня никаких особых тревожных сигналов.
Сценарий PHP запускается из командной строки в экземпляре Amazon EC2. ОС — Amazon Linux (RHEL).
Так что, в общем, я застрял. У кого-нибудь есть идеи, что может быть причиной этой проблемы?
-n NNNстрок и передать их в файл. затем очистите файл, удалив последний частичный элемент и добавив окончательный закрывающий тег (и) xml. возможно, найдите инструмент проверки xml. - person Jonathan Kuhn   schedule 20.12.2012