While using JS scripting with the mongo-shell API, how do I convert a JSON/BSON object into a XML string.
I would probably write the XML string to a file.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I grabbed the json2xml.js from here:
http://goessner.net/download/prj/jsonxml/json2xml.js
Then I saved it to the same folder as my mongo shell binary for convenience (so I didn’t have to specify the full path. Here are the results:
Now, you may need to extend this to deal with non-JSON types in MongoDB (see the BSON Specification page for details), but the basics are there.