2009-06-30 115 views
0

我使用simpleXML構建了一個站點以從XML頁面提取內容。簡單的XML在客戶端服務器上不起作用

我只是將網站切換到客戶端服務器,從XML表中拉出的頁面不再工作。

測試服務器是PHP 5.2.9版本

客戶端服務器是PHP 5.2.5版

allow_url_fopen是兩個服務器。

任何想法?

class award{ 
    var $xml; 
    var $awards; 

    function titles(){ 

     $this->fullArticle(); 
     $xml=simplexml_load_file("awards.xml"); 

     foreach($xml->award as $currentAward){ 
      $titles=$currentAward->title; 
      echo '<li><a href="'; 
      base_url(); 
      echo 'about/awards.php?award='; 
      echo $titles; 

      echo '">' . str_replace(array('<h1>','</h1>'), '', $currentAward->$titles->h1->asXML()) . '</a></li>'; 
      } 

    } 

    function fullArticle(){ 

     $awards=array(); 
     $xml=simplexml_load_file("awards.xml"); 

     foreach($xml->award as $currentAward){ 
      array_push($awards, $currentAward->title); 
     } 

     return($awards); 

    } 


    function articleBlock($awardy){ 


     $xml=simplexml_load_file("awards.xml"); 

     foreach($xml->award as $currentAward){ 
      if($currentAward->title = $awardy){ 
       echo str_replace(array('<'.$awardy.'>','</'.$awardy.'>'), '', $currentAward->$awardy->asXML()); 
      } 

      } 


    } 
} 
+0

代碼? – 2009-06-30 16:27:16

+0

我的代碼是波紋管 – chris 2009-06-30 16:42:33

回答

1

添加更多的錯誤處理和調試代碼

<?php 
assert_options(ASSERT_ACTIVE, 1); 
assert_options(ASSERT_BAIL, 1); 
assert_options(ASSERT_QUIET_EVAL, 1); 
error_reporting(E_ALL); 
ini_set('display_errors', 1); 

class award { 
    function titles() { 
     $xml=simplexml_load_file("awards.xml"); 
     if (!$xml) { 
      throw new Exception("cannot read awards.xml"); 
     } 

     assert(isset($xml->award)); 

     foreach($xml->award as $currentAward) { 
      assert(isset($currentAward->title)); 
      assert(isset($currentAward->$titles)); 
      assert(isset($currentAward->$titles->h1)); 

      $titles=(string)$currentAward->title; 
      echo '<li><a href="'; 
      base_url(); 
      echo 'about/awards.php?award='; 
      echo urlencode($titles); 

      echo '">' . str_replace(array('<h1>','</h1>'), '', $currentAward->$titles->h1->asXML()) . '</a></li>'; 
     } 
    } 
1

請檢查您的IP地址許可,您的服務器上啓用。如果沒有,然後啓用它。

相關問題