2010-11-25 30 views
0

我得到這個消息告訴了XML沒有被發現,但然後我得到的產品ID,產品名稱,我不知道我是怎麼能解決這個問題,請大家幫我找不到和codeigniter的xml?

/*文件結束的welcome.php //地點:./system/application/controllers/welcome.php * /文件「C:\用戶\阿毛裏\文件\ XML \ myxml.xmlwas沒有找到 產品ID產品名稱類別價格

這是我的代碼:

function _getXML($fname) 
{ 
    $filename = $fname.'.xml'; 
    $xmlfile="「C:\\Users\\beto\\Documents\\xml\\".$filename; 
    //$xmlRaw = file_get_contents($xmlfile); 
    $result = ''; 

    //$this->load->library('simplexml'); 
    //$xmlData = $this->simplexml->xml_parse($xmlRaw); 

    if(file_exists($xmlfile)){ 
     $xmlRaw = file_get_contents($xmlfile); 
     $this->load->library('simplexml'); 
     $xmlData = $this->simplexml->xml_parse($xmlRaw); 
     foreach($xmlData['Emisor'] as $row) 
     { 
      $result .= '<tr>'; 
      $result .= '<td>'.$row['id'].'</td>'; 
      $result .= '<td>'.$row['name'].'</td>'; 
      $result .= '<td>'.$row['category'].'</td>'; 
      $result .= '<td>$ '.$row['price'].'</td>'; 
      $result .= '</tr>'; 
     } 
    }else{ 
     $result = 'File' . $xmlfile . 'was not found'; 
    } 
    return $result; 
} 

回答

2

看起來你有一個額外的設置在你的道路上捲曲的引號。 "「C:\\

這是在你的實際代碼?這可能是你問題的原因。

「C:\\Users\\beto\\Documents\\xml\\myxml.xml將不存在,但C:\\Users\\beto\\Documents\\xml\\myxml.xml將。

+0

即使我改變目錄我得到相同的結果$ xmlfile =「」C:\ Users \ beto \ Documents \ xml \ myxml.xml「。 – bentham 2010-11-25 02:20:59