I am fetching XML file from remote url, but when '&' character occurs in XML, simplexml_load_file fails:
$url = 'https://domain.com/xml.php?xmlid=123;
print_r($url);
if (simplexml_load_file($url))
{
$orderDetailsXMLData = simplexml_load_file($url);
}
else
{
echo "Failed!";
}
XML sample file which fails is as follows:
Note, I don't have control over the source XML
1 Company1
<info>
<ccode>2</ccode>
<company>Company2</company>
</info>
<info>
<ccode>2</ccode>
<company>Company Sons & Sons</company>
</info>
</companies>
Is there any way to escape XML before importing?