cyberfly
11/30/2017 - 7:42 AM

PHP parse XML into object

<?php

$xml = '<?xml version="1.0" encoding="UTF-8"

<results>
<status>successful</status>
<staff_list>
<staff>
<staff_no>2554</staff_no>
<staff_name>Mohd Ali</staff_name>
<gender>Male</gender>
<email>muslin@dev.com.my</email>
</staff>
</staff_list>
</results>';

$xml_data = simplexml_load_string($xml);

$user_data = $xml_data->staff_list->staff;

?>