问题描述
我有一个 android 应用程序,我使用 POST 方法来获得响应.这是我的代码:
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();
但我不知道应该给 new InputSource()
什么,因为我必须使用 XML 类型 HTTPResponse 而不是 url.
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
这篇关于如何在 Android 中解析 xml 类型的 HTTPResponse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!