android解析服务器发过来的XML代码
2013-05-02 16:14
288 查看
//连接服务器 public static InputStream openConn(String path) { HttpURLConnection uc; URL url; InputStream is = null; try { url = new URL(path); // SocketAddress addr = new // InetSocketAddress("10.0.0.172",80);//是代理地址 // Proxy typeProxy = new Proxy(Proxy.Type.HTTP, addr); // uc = (HttpURLConnection) url.openConnection(typeProxy); uc = (HttpURLConnection) url.openConnection(); uc.connect(); is = uc.getInputStream(); //uc.disconnect(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return is; } //XML解析部分 InputStream is = openConn(你要解析的服务器的页面); //无法连接 if (is == null) return false; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = null; try { builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException e1) { // TODO Auto-generated catch block e1.printStackTrace(); |
相关文章推荐
- android解析来自服务器上的xml
- Android-SAX解析XML文件(http访问取回服务器XML)
- android解析xml和json数据(获取本地服务器数据)
- Android 开发XML解析,从服务器下载
- android生成及解析xml 模版代码
- Android XML解析——用Tomcat做服务器的问题
- Android代码小记之Xml解析工具类
- Android使用Http访问并解析服务器XML数据
- android中通过GET方法接收数据并通过xml解析数据,POST方法向服务器提交数据
- Android - 使用XmlPullParser解析从服务器得到的Xml数据
- Android-通过网络获取xml文件使用pull解析得到服务器中的信息(新闻客户端)
- Android解析本地服务器的XML文件
- Android笔记----对服务器XML以及JSON数据的简单解析
- android访问服务器并解析返回的XML和JSON数据
- 【Android技术整理】XML生成与解析伪代码
- android解析服务器传来的xml文件和json文件(一)
- Android中使用Json和Xml与服务器进行通信,使用代码发送Get和Post请求,http请求辅助类
- android中解析服务器发过来的JSON数据
- android中代码解析drawable的xml文件
- android 解析服务器数据使用json还是xml方式