I need to read the XML returned by API called in form of an URL, and convert in document format for further processing.
The URL is of form http://lookup.dbpedia.org/api/search.asmx/KeywordSearch?QueryClass=person&MaxHits=1&QueryString=Adam%20Sandler
. I referred the answer at read xml from url and used the following code. But the statement printed is "doc [#document: null]". What mistake am I doing?
String pre_apiURL = "http://lookup.dbpedia.org/api/search.asmx/KeywordSearch?QueryClass=person&MaxHits=1&QueryString=";
String apiURL = pre_apiURL + celeb + "";
apiURL = apiURL.replaceAll(" ","%20");
System.out.println("url "+apiURL);
URL url = new URL(apiURL);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(url.openStream());
System.out.println("doc " + doc.toString());