0

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!

1
Contributor
1
Reply
3
Views
5 Years
Discussion Span
Last Post by rouse
0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.