Parse XML from local file instead from URL

olgawild

New Member
i found/edited this code that parses XML from a url.is it possible to easily alter it to read from a local XML file?I found a lot of tutorials and posts about getResources().openRawResource() but i can't figure out what to change\[code\]...public static String getXML(){ String line = null; try { StrictMode.ThreadPolicy policy = new StrictMode. ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost("http://**************"); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); line = EntityUtils.toString(httpEntity); ... return line;}public static int numResults(Document doc){ Node results = doc.getDocumentElement(); int res = -1; try{ res = Integer.valueOf(results.getAttributes().getNamedItem("count").getNodeValue()); }catch(Exception e ){ res = -1; } return res;}\[/code\]...}
 
Back
Top