title: How to get xml response from URL in Java and store It in MONGODB
body: <p>I want to request one URL which will return a xml response like following:</p>
  
  <pre><code>&lt;SERVERPERFORMANCEMETRICS&gt;
  &lt;SERVERNAME&gt;abc&lt;/SERVERNAME&gt; 
  &lt;SERVERSTARTUPTIME&gt;11/25/2016 11:00 AM&lt;/SERVERSTARTUPTIME&gt; 
  &lt;TOTALMASTERREQUESTS&gt;4&lt;/TOTALMASTERREQUESTS&gt; 
  &lt;TOTALRENDERERREQUESTS&gt;13&lt;/TOTALRENDERERREQUESTS&gt; 
  &lt;FAILEDREQUESTS&gt;10&lt;/FAILEDREQUESTS&gt;
  &lt;/SERVERPERFORMANCEMETRICS&gt;
  </code></pre>
  
  <p>and now I want to parse and store this xml's data in MONGODB.</p>
  
  <pre><code>        URL url;
          HttpURLConnection urlConnection = null; 
  
  
          MongoClientURI mongoClientURI = new MongoClientURI(dbURL);
          MongoClient mongoClient = new MongoClient(mongoClientURI);
  
          /*  To connect database, you need to specify the database name, if the database 
              doesn't exist then MongoDB creates it automatically. */
          MongoDatabase mongoDatabase = mongoClient.getDatabase("myDb");
          System.out.println("Connected to database successfully");
  
          MongoCollection&lt;Document&gt; mongoCollection = mongoDatabase.getCollection("myCollection");
          System.out.println("Collection created successfully");
  
          url = new URL(targetURL);
          urlConnection =  (HttpURLConnection) url.openConnection();
          InputStream inputStream = urlConnection.getInputStream();
          InputStreamReader inputStreamReader =  new InputStreamReader(inputStream);
  </code></pre>