What is the best practice for loading XML data into an array in PHP?

When loading XML data into an array in PHP, the best practice is to use the SimpleXMLElement class to parse the XML data and convert it into an array. This class provides a simple and efficient way to work with XML data in PHP.

$xmlString = '<data><item>Item 1</item><item>Item 2</item></data>';
$xml = new SimpleXMLElement($xmlString);
$json = json_encode($xml);
$array = json_decode($json, true);

print_r($array);