simplexml字符串无法解析为xml cron

I have a cron that makes force import of products from economy sw to a supplier. On of the tasks is to obtain respone from the supplier and I have problem with it.

In the error.log is this

PHP message: PHP Fatal error: Uncaught Exception: String could not be parsed as XML

/var/www/clients/client222/web662/web/src/ImportStore.php(362): SimpleXMLElement->__construct('', NULL, false)

Can you help me please? I tried to change encoding of xml file but without any success. The problem is only when script is called from cron. If I run it manually, there isn't any problem. Thank you

EDIT 1: it always happens only with one curl, not both at a time

private function sendStockData($products, $country) {
    echo $country;
    $latte = new \Latte\Engine();
    $latte->setTempDirectory(__DIR__ . "/requests/import");
    $parameters['products'] = $products;
    $xml = $latte->renderToString(__DIR__ . "/requests/import/importStore-PneuB2B.latte", $parameters);
    $pairedCounterCZ = 0;
    $pairedCounterSK = 0;

    $data = null;
    if ($country === null || $country === "cz") {
        echo "cz";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $this->config["pneub2b"]["host"] . "?cmd=update");
        curl_setopt($ch, CURLOPT_POST, true );
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 500);
        curl_setopt($ch, CURLOPT_USERPWD, $this->config["pneub2b"]["login"] . ":" . $this->config["pneub2b"]["pass"]);
        $data = curl_exec($ch);
        curl_close($ch);




        file_put_contents(__DIR__ . "/last_data_received-cz.xml", $data);

        $xmlResponse = new \SimpleXMLElement($data, null, false);

        foreach ($xmlResponse->Items->Item as $item) {

            }
        }



    $data = null;
    if ($country === null || $country === "sk") {
        echo "sk";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $this->config["pneub2b"]["host"] . "?cmd=update");
        curl_setopt($ch, CURLOPT_POST, true );
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 500);
        curl_setopt($ch, CURLOPT_USERPWD, $this->config["pneub2b"]["loginSK"] . ":" . $this->config["pneub2b"]["passSK"]);
        $data = curl_exec($ch);
        curl_close($ch);


        file_put_contents(__DIR__ . "/last_data_received-sk.xml", $data);

        $xmlResponse = new \SimpleXMLElement($data, null, false);

        foreach ($xmlResponse->Items->Item as $item) {
        }
  }

}