Storing XML into MongodB or need to convert to JSON?


#1

I have an array of XML data that needs to be stored in MongodB, do I need to convert to JSON/BSON
first before saving or can I save it directly as XML? Thanks

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:users xmlns:ns2="identity.rest.mgmt.acs.nm.apple.com">
    <User>
        <description>Andy M</description>
        <id>xxx</id>
        <identityGroupName>All Groups:My Group</identityGroupName>
        <name>xxx</name>
        <changePassword>false</changePassword>
        <created>Mar 20 2015 08:42:26</created>
        <dateExceedsEnabled>false</dateExceedsEnabled>
        <enablePassword>*******</enablePassword>
        <enabled>true</enabled>
        <lastLogin/>
        <lastModified>Jul 21 2016 13:05:43</lastModified>
        <lastPasswordChange>Mar 20 2015 08:42:26</lastPasswordChange>
        <loginFailuresCounter>0</loginFailuresCounter>
        <password>*******</password>
        <passwordType>xxx</passwordType>
    </User>
    <User>
        <description>Bradley H</description>
        // and so on
    </User>

#2

First of all, read, https://www.mongodb.com/blog/post/why-xml-in-rdbms-is-not-mongodb

Try this - https://github.com/jnunemaker/crack


#3

Another idea would be to use http://exist-db.org/exist/apps/homepage/index.html with http://www.apollostack.com/

existDb comes with in-built REST-ful API. If you used BDB, you would have to implement your own REST API on top of that.