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:

<?php
                $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.
Thanks!

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.