Start New Discussion within our Web Development Community

I have problem getting XML file with curl.
I get empty XML and error:

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "1" in /home2/public_html/xmlupdate.php on line 62
xml 1 not loaded.

the code for curl:

    $ch =curl_init();
    curl_setopt($ch, CURLOPT_URL,$xml_url_1);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($ch, CURLOPT_CAINFO, realpath("certs/ca.pem"));
    curl_setopt ($ch, CURLOPT_SSLCERT, realpath("certs/client.pem"));
    curl_setopt($ch, CURLOPT_SSLKEY, realpath("certs/key.pem"));
    curl_setopt($ch, CURLOPT_SSLKEYPASSWD, "2255"); 
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)');
    $xml_url = curl_exec ($ch);
    echo curl_error($ch);
    curl_close ($ch);

    $xml = simplexml_load_file(utf8_encode($xml_url), 'SimpleXMLElement', LIBXML_NOCDATA);

When I acces XML with web broser it works, there is something wrong in my curl code.

Any ideas?



curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

And try simplexml_load_string here:

$xml = simplexml_load_file(utf8_encode($xml_url), 'SimpleXMLElement', LIBXML_NOCDATA);


Thanks, overlooked your post

Hi I have added it, and I get:

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "<?xml version='1.0' encoding='UTF-8'?> <NewDataSet> <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://ww in /xml.php on line 62

When I echo it I het plain text in web page

I had to use:

That was the problem because of the string :)

This question has already been answered. Start a new discussion instead.