在android中解析XML通过HttpPOST [英] Parsing an XML getting through HttpPOST in android

查看:107
本文介绍了在android中解析XML通过HttpPOST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在执行httpPOST期间,我将响应存储为字符串,我得到的响应是这样的:



During the execution of a httpPOST i store the response as a String and the response i am getting is like this:

<?xml version = "1.0" encoding= "utf-8"?>
      string xmlns="http://localhost:4471/">101~Success</string>









我只想在解析后获得101~成功,这样我就可以通过使用split函数获得101但是我无法在android中获得这个元素。我在

J2ME中得到了这个: />




InputStream in = new ByteArrayInputStream(strResponse.getBytes(UTF-8));

InputStreamReader is = new InputStreamReader(in);

parser = new XmlParser(is);

doc.parse(parser);



元素root = doc.getRootElement();

元素item = doc.getElement(2);

String parsedResponse = item.getText(0 );



如何使用DOM或XmlPullParser在android中执行此操作?





I just want to get 101~Success after parsing so that i can get 101 by using split function but am not able to get this element in android.I was getting this in
J2ME as:


InputStream in = new ByteArrayInputStream(strResponse.getBytes("UTF-8"));
InputStreamReader is = new InputStreamReader(in);
parser = new XmlParser(is);
doc.parse( parser );

Element root = doc.getRootElement();
Element item = doc.getElement(2);
String parsedResponse = item.getText(0);

How can i do it in android using DOM Or XmlPullParser?

推荐答案

我没有关于android的任何想法,但在dom你可以使用getTextContent()方法来提取内容。
I dont have any idea about android but in dom you can you use getTextContent() method to extract the content.


这篇关于在android中解析XML通过HttpPOST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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