I have the following xml:
$resultXML=<<<XML
<Mapper ProviderCode="" ProviderName="" SessionID="" Supplier="" ProviderSupplier="">
<ProviderSupplierName/>
</Mapper>
XML;
When I issue:
$sxml = simplexml_load_string($resultXML);
echo json_encode($sxml);
in PHP Version 5.3.3-7+squeeze15, I get:
"Mapper": {
"@attributes": {
"ProviderCode": "",
"ProviderName": "",
"SessionID": "",
"Supplier": "",
"ProviderSupplier": ""
},
"ProviderSupplierName": {}
}
while in PHP Version 5.4.4-14+deb7u8, I get:
"Mapper": {
"0": {},
"@attributes": {
"ProviderCode": "",
"ProviderName": "",
"SessionID": "",
"Supplier": "",
"ProviderSupplier": ""
}
}
I want to use PHP Version 5.4.4-14+deb7u8 and get same result as PHP Version 5.3.3-7+squeeze15.
Actually this xml is part of a very long xml. When I extract it as in this case, i get similar results on both versions of php.
The full xml can be found at https://drive.google.com/file/d/0B9zOzk6voXHKQ3N1ZklfVFVITFU/edit?usp=sharing
Another thing I noticed is that if I use the xml as given in link, I get the json as in the second example, but if I use an xml formatter and format the xml, then I get the json in the first example.
Any help?
json_encodedid not change. But perhaps that ofsimplexml_load_stringdid.