I have xml data like this
$message= '<Messages name="AccountData" MessageID="IN202209090001" type="IncomingMessage"><Record name="recordAccount"><Field name="externalReference">er20220909001a</Field><Field name="memberID">abc</Field><Field name="participantCode">AA</Field><Field name="description">John woo</Field><Field name="investorMemberUID">AA01</Field><Field name="uniqueIdentifier">AA0166</Field><Field name="accountTax">ID</Field><Field name="accountingBalanceSide">PASSIVE</Field><Field name="type">DEPOSITORY</Field><Field name="status">AVAILABLE</Field><Field name="paymentBankUID">KSEPB</Field><Field name="correspondentAccountNumber">123</Field><Field name="lastUpdateTimestamp">20220999161</Field><Field name="number">AA00166</Field></Record></Messages>' ;
i try to get all value from that message,
then i write code like this
$json = json_encode($message,true);
$xml = json_decode( str_replace( ‘`’, ‘"’, $json ), true );
if i add code
echo $xml[‘MessageID’] ,after run i got message "PHP Warning: Illegal string offset ‘MessageID’ "
if i add code
echo $xml->MessageID; , after run i got message "Notice: Trying to get property ‘MessageID’ of non-object "
please help