Warning while load xml using the DOMDocument
I used the following code to load the xml for further process, while load itself it display the following warning in the client server but its working fine in my local machine.
Code:
$xmlDoc = new DOMDocument();
$xmlDoc->load('http://www.domainname.com/xmlfilename');
Warning: DOMDocument::load(http://www.domainname.com/xmlfilename) [domdocument.load]: failed to open stream: Connection timed out
Warning: DOMDocument::load() [domdocument.load]: I/O warning : failed to load external entity "http://www.domainname.com/xmlfilename"
开发者_StackOverflow中文版
Increase the time until Connection Timeout before calling load
:
libxml_set_streams_context(
stream_context_create(
array('http' => array('timeout' => 120))
)
);
or
ini_set('default_socket_timeout', 120);
See
libxml_set_streams_context
— Set the streams context for the next libxml document load or write- HTTP Context Options
- Ini Setting:
default_socket_timeout
First, make sure your client's server is configured with allow_url_fopen
set to true
.
I'd also be checking firewall rules on the server. Perhaps it's not allowed to make HTTP requests.
精彩评论