Android4.0使用dom解析
来源:互联网 发布:mac怎么关闭加密文件夹 编辑:程序博客网 时间:2024/06/01 10:36
SDomParese.getWeather(url2);public static void getWeather(String uri) {try {DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();DocumentBuilder builder = factory.newDocumentBuilder();InputStream is = HttpUtils.getInputStremFromXml(uri, "utf-8");Document document = builder.parse(is);Element root = document.getDocumentElement();NodeList list = root.getElementsByTagName("s");for (int i = 0; i < list.getLength(); i++) {Element element = (Element) list.item(i);GlobalConstant.i("k--->>" + element.getAttribute("k"));GlobalConstant.i("d--->>" + element.getAttribute("d"));}} catch (Exception e) {GlobalConstant.i("dom parse exception-->" + e);e.printStackTrace();}}
/** * * 返回inputstream类型的xml数据 * * @param path * @param encode * @return */public static InputStream getInputStremFromXml(String path, String encode) {HttpClient httpClient = new DefaultHttpClient();try {HttpPost httpPost = new HttpPost(path);HttpResponse httpResponse = httpClient.execute(httpPost);if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {HttpEntity httpEntity = httpResponse.getEntity();return httpEntity.getContent();}} catch (Exception e) {System.out.println("get stream exception--->" + e);e.printStackTrace();} finally {httpClient.getConnectionManager().shutdown();}return null;}
0 0
- Android4.0使用dom解析
- Android4.0 Loaders使用方式解析
- Android4.0 使用pull解析xml
- Android4.0和Android2.3,2.2以及其他版本DOM解析XML问题
- Android4.0 EXIF解析
- 使用Dom解析XML
- DOM 解析器 使用
- 使用dom解析xml
- 使用DOM解析XML
- 使用DOM解析XML
- 使用dom解析
- Android4.0 input touch解析
- Android4.0 input touch解析
- android4.0 Switch方法解析
- Android4.0 input touch解析
- Android4.0 input touch解析
- Android4.0 input touch解析
- java解析xml:使用DOM
- 反光镜反光镜的房间付定金打飞机
- 淘宝技术这十年
- HibernateTemplate中的HibernateCallBack事务
- 文献管理软件简介
- 我今天很开心吖
- Android4.0使用dom解析
- 今天木有下雨吗
- 防止SQL注入漏洞简单方法
- 用定时器发送消息,activemq总是报WARN报错
- 获取Android签名证书的sha1值
- windows系统虚拟机上安装ubuntu之后,设置ubuntu系统与windows系统之间的共享文件
- POJ3311
- 程序员的奋斗史(三十一)——人在囧途之应聘篇(一)
- 嵌入式Linux学习站点