I recommend using the xml2json python package to convert back and forth from XML/JSON.
-
Install it with pip:
pip install xml2json
-
Convert a file:
xml2json -t xml2json -o output.json input.xml --strip_text
The output JSON won't be pretty printed (as in the attached file, but it will be valid!!)