我正在开发一个Android应用程序,其中我在listview中有5个项目。我无法在列表视图中获取我的数据,...我已经尝试了所有的东西,,,但是在listview中没有任何东西
我的网址是
http://harpreetvir.web708.discountasp.net/PMevents/XmlRecord/AddEvent.xml
我的ddms logcat是http://pastebin.com/YH0JWiRJ
有人可以帮忙吗?
答案 0 :(得分:0)
请仔细阅读以下代码。
try {
HttpClient client = new DefaultHttpClient();
String postURL = "http://harpreetvir.web708.discountasp.net/PMevents/XmlRecord/AddEvent.xml";
HttpGet post = new HttpGet(postURL);
HttpResponse responsePOST = client.execute(post);
HttpEntity resEntity = responsePOST.getEntity();
String str1=EntityUtils.toString(resEntity);
str1=str1.trim();
parsing(str1);
}
catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
public void parsing(String str1) throws XmlPullParserException, IOException{
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput( new StringReader (str1));
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
String str;
if(eventType == XmlPullParser.START_DOCUMENT) {
System.out.println("Start document");
} else if(eventType == XmlPullParser.START_TAG) {
str = xpp.getName();
System.out.println("Start tag "+str);
} else if(eventType == XmlPullParser.END_TAG) {
System.out.println("End tag "+xpp.getName());
} else if(eventType == XmlPullParser.TEXT) {
System.out.println("Value= "+xpp.getText());
}
eventType = xpp.next();
}
System.out.println("End document");
}