PHP 7.1 The problem is that I have a well formated XML file. I know that it's well formated, because we are generating XML files for the clients, and the only problem now is that I put it into an XML file instead of reading it from the response, and I cant read it back. To the point:
Test comes back with this error message. As you can see there is a backslash character before the < characters and I dont know why it is there because it's not in the file, and I'm 100% sure that's the problem because I always got errors, like "trying to get property of a non object" or something similar.
[37;41;1m [PHPUnit_Framework_Exception] simplexml_load_file(): I/O warning : f
ailed to load external entity "\<?xml version="1.0"?>
\<AudioDoc name="JustEat16727D1InHomeRUSHES1" path="JustEat16727D1InHomeRUSHES1.
mp3">
\<ProcList> [39;49;22m
[37;41;1m
Code what I'm working with.. well hard to choose, because almost anything, which can be found on the internet. Actually I need a SimpleXMLElement object. So I read the file like something like this:
$xml = simplexml_load_string($xmlPath);
or
$xml = new SimpleXMLElement(file_get_contents($xmlPath));
or
$xml = simplexml_load_string(file_get_contents($xmlPath));
I tried all, and then I check it in codeception with this line:
$I->assertInstanceOf(SimpleXMLElement::class, $xml, 'Input type is xml');
and ofc I got no errors. Then I call the function where I would like to work with it, where the function header looks like this:
public static function mergeXml(SimpleXMLElement $xml, $content)
so if it wouldn't be a SimpleXMLElement, then it should throw an error here too. And then I would like to use it, and I got the errors, like above.
As I said this function works correctly when I got the xml from the response, but since it's a 3rdparty API, and extremely slow - like 1.5 hours to get the XML back, because it's a speech to text service - and I wouldn't be here at all if they wouldn't have a bug in the API - I have to do it by myself from the xml file with a little modification.
The XML is like 1805kb, but I dont think that it would be a problem, because the code can read it with the another way
So. Is there someone here who might has an idea what could be the reason that it's handling the XML as a string? Or what is the reason for the \ characters?
Any help is appreciated!