<?php
$xml = simplexml_load_file('http://www.etdexpress.com/TrackingXML.aspx?trackingcodes=20600000075_20100000011');foreach($xml as $item)
{
var_dump($item);
echo "\r\n<br>";
echo "\r\n<br>";
foreach ($item->TrackingInfo as $resulte){
$info = $resulte->attributes();
var_dump($info['ActionDate']);
echo "\r\n<br>";
echo "\r\n<br>";
}
//var_dump($arr['ActionDate']);
//getXMLnode($item,)
echo "\r\n<br>";
echo "\r\n<br>";
}
?>以上代码在我本地可以正常运行
但是放到linux服务器上就只显示空白页面
我测试了如果把url换成http://www.abc.com/1.xml这种形式的话 就可以在服务器上运行
请达人告知,应该是服务器设置的问题,具体是哪里出了问题还请明示   (顺便做个广告哈,小弟的个人站艾莱依旗舰店-艾莱依羽绒服专卖店)补充:服务器php.ini的设置allow_url_fopen = On也打开了

解决方案 »

  1.   

    错误报告一直打开的没有提示
    而且打印$xml返回的是false
      

  2.   

    测试成功  linux(ubuntu 10+)  mac 10.6.6
      

  3.   


    注意一下PHP的版本,早期的PHP版本需要再进一些参数处理simplexml_load_file
    (PHP 5)simplexml_load_file — Interprets an XML file into an object 说明
    object simplexml_load_file ( string $filename [, string $class_name = "SimpleXMLElement" [, int $options = 0 [, string $ns [, bool $is_prefix = false ]]]] )
    Convert the well-formed XML document in the given file to an object. 参数filename 
    Path to the XML file Note: Libxml 2 unescapes the URI, so if you want to pass e.g. b&c as the URI parameter a, you have to call simplexml_load_file(rawurlencode('http://example.com/?a=' . urlencode('b&c'))). Since PHP 5.1.0 you don't need to do this because PHP will do it for you. 
      

  4.   

    刚好今天在做这个功能,可以考虑使用file_get_content('http://www.etdexpress.com/TrackingXML.aspx?trackingcodes=20600000075_20100000011')来完成,但是一定要注意你访问的这个文件是符合标准的XML文档,不然在解析时肯定会出错
      

  5.   


    我的版本是PHP Version 5.2.6-1+lenny8 Since PHP 5.1.0 you don't need to do this because PHP will do it for you. 所以应该没问题啊~
      

  6.   

    你在你的服务器上测试成功对我一点帮助都没有 我的本地也是一点问题也没有,关键是服务器上是哪里的问题 是php设置的问题还是其他方面呢
      

  7.   

    查看 phpinfo 对比看看是否缺少什么模块
      

  8.   

    报错:
     Warning: simplexml_load_file(http://www.etdexpress.com/TrackingXML.aspx?trackingcodes=20600000075_20100000011)  [function.simplexml-load-file]: failed to open stream: HTTP request failed! 
      

  9.   


    代码在我这边测试没问题,应该是扩展的原因了,你检查一下phpinfo();看一下是否有SimpleXML
    Simplexml support enabled 
    Revision  $Revision: 299424 $  
    Schema support  enabled  
    没有的话就不行,再检查一下其他的扩展是否正确打开了
      

  10.   

    SimpleXML
    Simplexml support enabled  
    Revision $Revision: 299424 $   
    Schema support enabled   这个是支持的 但不知道还有哪块没有打开~