开发者

file_get_contents error in php with codeigniter?

I am doing this tutorial but with a diferent xml http://blog.insicdesigns.com/2009/03/parsing-xml-file-using-codeigniters-simplexml-library/, but I keep getting the same error: A PHP Error was encountered Severity: Notice Message: Undefined variable: myxml Filename: controllers/welcome.php Line Number: 45

this my mi code: I put the xml file in the directory C:\Users\beto\Documents\xml\myxml.xml, but I think I am wron开发者_如何学编程g can you help me, or tell me how to fix it?

function _getXML($fname)
  {

      $filename = $fname.’.xml’;
      $xmlfile=“C:\\Users\\beto\\Documents\\xml”.$filename;
      **$xmlRaw = file_get_contents($xmlfile);**ERROR

      $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>’;

      }
        return $result;
  } 


a \ is missing, replace like:

$xmlfile="C:\\Users\\beto\\Documents\\xml\\".$filename;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜