title: how to insert xml file data into mongodb database using java?
body: <p>how can i insert xml file data/contents (which is already exist in a disk) into MongoDB database using java?</p>
  
  <p>please any one can resolve it.</p>
  
  <p>//Edited code</p>
  
  <pre><code>XmlMapper xmlMapper = new XmlMapper();
          List entries = xmlMapper.readValue(new File("C:/Users/manish/Desktop/BaseX65/xml/books.xml"),List.class);
  
          ObjectMapper jsonMapper = new ObjectMapper();
          String json = jsonMapper.writeValueAsString(entries);
  
          try
           {
  
                  Mongo mongo = new Mongo("localhost", 27017);
                  DB db = mongo.getDB("newdb");
  
                  DBCollection collection = db.getCollection("dummyColl");
  
  
                  DBObject dbObject = (DBObject)JSON.parse(json);
  
                  collection.insert(dbObject);
  
                  DBCursor cursorDocJSON = collection.find();
                  while (cursorDocJSON.hasNext()) {
                      System.out.println(cursorDocJSON.next());
                    }         
           }
  </code></pre>