- simplexml_load_string: documentation ( source)
- function_exists: documentation ( source)
- json_encode: documentation ( source)
<?php
if( !function_exists('simplexml_load_string') || !function_exists('json_encode') ) die('Not supported yet');
$data = array(
<<<XML
<Hotels1>
<Hotel>
<Mapper><ProviderSupplierName/></Mapper>
</Hotel>
</Hotels1>
XML
,
<<<XML
<Hotels1>
<Hotel>
<Mapper>
<ProviderSupplierName/>
</Mapper>
</Hotel>
</Hotels1>
XML
);
foreach($data as $resultXML){
echo $resultXML . PHP_EOL;
$sxml = simplexml_load_string($resultXML);
echo json_encode($sxml,LIBXML_NOBLANKS);
echo PHP_EOL;
}