How to convert xml into array in php? I want to convert the XML structure below into a PHP array.

&lt;BillingApplyRq&gt;
    &lt;FatoryId&gt;xxxxxx&lt;/FatoryId&gt; 
    &lt;TotalNum&gt;2&lt;/TotalNum&gt; 
    &lt;Records&gt; 
        &lt;Record&gt; 
            &lt;ReturnMsgNo&gt;1&lt;/ReturnMsgNo&gt; 
            &lt;ReturnMsg&gt;&lt;/ReturnMsg&gt; 
            &lt;TradeSeq&gt;00001&lt;/TradeSeq&gt; 
        &lt;/Record&gt; 
        &lt;Record&gt; 
        &lt;ReturnMsgNo&gt;1&lt;/ReturnMsgNo&gt; 
        &lt;ReturnMsg&gt;&lt;/ReturnMsg&gt; 
        &lt;TradeSeq&gt;00002&lt;/TradeSeq&gt; 
        &lt;/Record&gt; 
    &lt;/Records&gt; 
&lt;/BillingApplyRq&gt;


Does anyone know how to do that?
Although this is not related to Drupal but anyway you must convert from XML to array by using the sample code below from PHP.net

$simple = "&lt;para&gt;&lt;note&gt;simple note&lt;/note&gt;&lt;/para&gt;";
$p = xml_parser_create();
xml_parse_into_struct($p, $simple, $vals, $index);
xml_parser_free($p);
echo "Index array\n";
print_r($index);
echo "\nVals array\n";
print_r($vals);


Ref: xml_parse_into_struct — Parse XML data into an array structure