奇怪的XMLReader错误(仅在主机上,本地工作)

时间:2013-07-22 11:47:47

标签: php xml

错误:

[xmlreader.open]: failed to open stream: HTTP request failed! HTTP/1.0 500 Internal Server Error in /var/www/html/www/main_web_mobile/index.php on line 54

Warning: XMLReader::open() [xmlreader.open]: Unable to open source data in /var/www/html/www/main_web_mobile/index.php on line 54

Warning: XMLReader::read() [xmlreader.read]: Load Data before trying to read in /var/www/html/www/main_web_mobile/index.php on line 59

代码:

<?      $z = new XMLReader;
        $z->open('http://URL_HERE');

        $doc = new DOMDocument;

        while ($z->read() && $z->name !== 'item');

        while ($z->name === 'item')
        {
            $node = simplexml_import_dom($doc->importNode($z->expand(), true));
            ?>
            <h2 class="acc_trigger"><a href="#"><?php echo $node->title; ?> | <strong><?php echo $node->speciality; ?></strong></a></h2>
            <div class="acc_container">
                <div class="main_text">
                    <div class="title"><?php echo $node->title; ?> |<strong> <?php echo $node->speciality; ?></strong></div>
                    <div class="text_holder"><?php echo $node->descriptionWithoutImage; ?></div>
                    <div class="img_holder"><img src="<?php echo $node->image; ?>" alt="" /></div>
                </div>
               <a href="tel: <?php echo $numberbefore; ?>"><div class="btn_holder"><?php echo $number; ?><br /><div class="call_now"><div class="extention"><?php echo $node->internalNumber; ?></div></div></div></a>
            </div>
            <?php 
            $z->next('item');
        }
        ?>

2 个答案:

答案 0 :(得分:2)

从错误中可以清楚地看出,您的服务器无法访问http://URL_HERE。要么你有网络限制;或者您的服务器上已禁用allow_url_fopen

答案 1 :(得分:0)

在浏览器中输入http://URL_HERE时,您是否可以访问您的文件?

问题可能是主机上的访问限制,例如尝试更改chmod。