I am writing some learning code to convert an XML file to a JavaScript array.
So far I can convert from XML to JSON with this:

                $xmlStr = simplexml_load_file("xml/galleryXML.xml");
                $jsonStr = json_encode($xmlStr);

I don't know and can't find a way to convert to a JavaScript array object. Is there a clear method to do this? I can't find a method in PHP or JavaScript with a web search so far.

I was able to write some code, mostly in JavaScript to do this for my singular XML file, but not for a generic XML file.