上传XML文件并传入存储在cookie中的数组

I've seen snippets of code on how to create an associative array from an XML file, however I'm unsure on how to have a system where the user can upload their own XML file, and it creates the associative array from the uploaded file and then stores the array inside of a cookie.

Any help is greatly appreciated.

Does it have to be an associative array? Otherwise you could check out simplexml_load_file($filename)

Adding to Big Ginger Nerd's suggestion:

$xml = simplexml_load_file($filename);
$json = json_encode($xml);
$array = json_decode($json,TRUE);

This converts it to JSON and then back to an associative array. +1 to Big Ginger Nerd and the suggestions on the PHP SimpleXML manual page.