我尝试使用xml,但我在线上获得了NullPointerException:
InputStream is = res.getEntity().getContent();
我的消费方法可以检查网址中的xml
public class XMLDownloader {
DefaultHttpClient client = new DefaultHttpClient();
HttpGet method = new HttpGet("http://proapaplicativos.com.br/jccuritiba/listarEventos.php");
HttpResponse res = null;
NodeList result = null;
// Thread t = new Thread();
public NodeList GetNodeList() throws InterruptedException{
//String url = "http://fiscalartesp.cloudapp.net/Service1.svc/login?";
new Thread(new Runnable() {
public void run() {
try {
res = client.execute(method);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try{
URL urls;
urls = new URL("http://proapaplicativos.com.br/jccuritiba/listarEventos.php");
InputStream is = res.getEntity().getContent();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new InputSource(urls.openStream()));
doc.getDocumentElement().normalize();
result = doc.getElementsByTagName("Evento");
is.close();
}catch(Exception e){
Log.i("log_tag", "Error converting result "+e.toString());
}
}
}).start();
/*
new Thread(new Runnable() {
public void run() {
}).start();
*/
while(result == null)
{
//Log.i("Aguardando", "Aguardando resposta");
}
return result;
}
}