WEB开发网      濠靛倻鏅悵顖涚附閽樺鐎诲ù婊庡亾缁辨帗鎷呴悩鍨暠濞戞挴鍋撳ù鐘烘閸ㄥ孩绂嶉锝喰﹂柟瀛樺灣濠婃垿鎯冮崟顏嗩伇濞寸姾妫勬慨鈺呭礉濞戝磭骞㈤悹鍥у槻閸ㄥ孩绂嶉敓锟� ---闁挎洩鎷�
开发学院手机开发Android 开发 Android的HTTP通信 XML解析和异步消息处理 阅读

Android的HTTP通信 XML解析和异步消息处理

 2010-02-03 19:10:00 来源:WEB开发网 闁靛棴鎷�闁告垵绻愰惃顒傗偓娑欍仦缂嶏拷濠⒀呭仜閵囧洨鈧稒銇炵紞锟�闁靛棴鎷�  闁稿繗娅曢弫鐐次涘▎鎰泚闁告娲ㄥ▓鎴濐嚗椤旂厧瑙�
核心提示:mResult += "name:" + attributes.getValue("name");}// 一发现元素结束标记就回调此函数@Overridepublic void endElement(String uri, String localName, String qNa

mResult += " name:" + attributes.getValue("name");

}

// 一发现元素结束标记就回调此函数

@Override

public void endElement(String uri, String localName, String qName)

throws SAXException {

if (localName == "title")

mIsTitleTag = false;

else if (localName == "salary")

mIsSalaryTag = false;

else if (localName == "dateOfBirth")

mIsBirthTag = false;

}

// 一发现元素值或属性值就回调此函数

@Override

public void characters(char[] ch, int start, int length)

throws SAXException {

if (mIsTitleTag)

mResult += new String(ch, start, length);

else if (mIsSalaryTag)

mResult += " salary:" + new String(ch, start, length);

else if (mIsBirthTag)

mResult += " dateOfBirth:" + new String(ch, start, length);

}

public String getResult(){

return mResult;

}

}

Main.java

代码

package com.webabcd.communication;

import java.io.BufferedInputStream;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.net.HttpURLConnection;

import java.net.URL;

import java.net.URLConnection;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.Map;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import javax.xml.parsers.SAXParser;

import javax.xml.parsers.SAXParserFactory;

import org.apache.http.HttpEntity;

import org.apache.http.HttpResponse;

import org.apache.http.client.entity.UrlEncodedFormEntity;

上一页  1 2 3 4 5 6 7  下一页

Tags:Android HTTP 通信

编辑录入:coldstar [复制链接] [打 印]
赞助商链接