Java tutorial
//package com.java2s; import java.net.URL; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { public static Document getdoc(String uri) throws Exception { uri = uri.replace(" ", "%20"); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = null; db = dbf.newDocumentBuilder(); Document doc = db.newDocument(); doc = db.parse(new URL(uri).openStream()); if (doc == null || doc.getTextContent() == "") { throw new Exception(); } else return doc; } }