如何使用php处理XML响应


how to handle XML response with php

我需要ping该URL并接收响应:

http://test.cellpay.com.np:8181/cellcom?FN=123&fromMobile=01670746301&phoneNumber=01970746301&PIN=1234567890&amount=0

响应是XML格式的。我正在尝试使用PHP读取响应。如果我使用:

file_get_contents($url);

它显示:

file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0

如果我使用:

file_get_contents($url);

它显示:

bool(false) 
Uncaught exception 'Exception' with message 'String could not be parsed as XML'

我不知道该怎么办,请帮帮我。

谢谢。

http://wrapper在服务器配置中被禁用allow_url_fopen=0

您的服务器不允许使用PHP流包装器打开http URL。您可以尝试使用ext/curlfsockopen()。但是,您的Server/PHP可能只是没有配置为支持传出连接。

!!!!!!!!!终于解决了这就是php版本的全部内容我正在尝试从PHP 5.4.27,不起作用。。。。最后从PHP 5.6.3进行了尝试,它成功了。如此简单而神奇。

感谢Veenex和file_get_contents返回空字符串为了所有的努力。

谢谢你们,非常感谢。