如何解析XML类型HTT presponse Android中 [英] How to parse a xml type HTTPResponse in Android

查看:87
本文介绍了如何解析XML类型HTT presponse Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android应用程序,其中我使用POST方法得到回应。这里是我的code:

I have an android application where I use POST method to get a response. here is my code:

..........................................
HttpResponse httpResponse = httpclient.execute(httppost);
HttpEntity resEntity =  httpResponse.getEntity();

这工作得很好,我也得到XML格式的响应,但我想解析xml文件,并得到该节点的值。我想这样的:

this works fine and i get a response in xml format but i want to parse that xml file and get the node values. i tried this :

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new InputSource());
doc.getDocumentElement().normalize();

但我不知道应该给新的InputSource(),因为我必须使用XML类型HTT presponse不是一个网址。

but I don't know what should give to new InputSource() because I have to use a XML type HTTPResponse not a url.

谢谢!

推荐答案

好,谢谢大家的回复。我只是找到了一种方法来解决我的问题。 http://www.rgagnon.com/javadetails/java-0573.html

ok thanks everyone for the replies. i just found out a way to overcome my problem. http://www.rgagnon.com/javadetails/java-0573.html

这篇关于如何解析XML类型HTT presponse Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆