我目前在导入大型 XML 文件时遇到问题,我不知道为什么。我们从合作伙伴那里得到一个大小约为 443MB 的 XML 输出。我得到的错误如下:
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 都在一行上,所以它无法优雅地处理,即使在具有 32GB RAM 和 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)
所以,基本上,我被卡住了。有没有人知道什么可能导致这个问题?