15 public static function convert($xmlData, $convertCharset =
true)
22 if($convertCharset && mb_strtolower(SITE_CHARSET) !=
'utf-8')
23 $xmlData = \Bitrix\Main\Text\Encoding::convertEncoding($xmlData, SITE_CHARSET,
'UTF-8');
25 if(preg_replace(
'/[[:^print:]]/',
'', $xmlData) ==
"<?xml version='1.0' encoding='UTF-8'?>")
29 libxml_use_internal_errors(
true);
33 $results = new \SimpleXMLElement($xmlData, LIBXML_NOCDATA);
40 'TRADING_PLATFORM_XML2ARRAY_ERROR',
42 'Can\'t convert xmlData to SimpleXMLElement. Data: ('.$xmlData.
'). Error: '.$e->getMessage()
53 'TRADING_PLATFORM_XML2ARRAY_ERROR',
55 'Wrong xmlData format. Data: ('.$xmlData.
').'
60 elseif($jsonString = json_encode($results))
62 $result = json_decode($jsonString, TRUE);
65 if(mb_strtolower(SITE_CHARSET) !=
'utf-8')
66 $result = \Bitrix\Main\Text\Encoding::convertEncoding($result,
'UTF-8', SITE_CHARSET);