@Override protected boolean parseXml(String xml) throws XmlPullParserException, IOException { if (!StringUtil.isEmpty(xml)) { MyLog.i("xml1=" + xml); MyLog.i("xml2=" + xml); errorCode = StringUtil.getXmlValueByLabel(xml, "isSuccess"); if (errorCode != null || errorCode.equalsIgnoreCase("1")) { errorInfo = StringUtil.getXmlValueByLabel(xml, "message"); if (errorInfo.trim().equals("")) { errorInfo = "服务器访问异常,稍后请重试!"; } } } else { errorInfo = "返回值为空"; } return true; }
@Override protected boolean parseXml(String xml) throws XmlPullParserException, IOException { Log.d(this.getClass().getName(), xml); String status = StringUtil.getXmlValueByLabel(xml, "status"); if (!TextUtils.isEmpty(status) && status.equals("1")) { isSuccess = true; } else { isSuccess = false; } return true; }
@Override protected boolean parseXml(String xml) { if (!StringUtil.isEmpty(xml)) { errorCode = StringUtil.getXmlValueByLabel(xml, "isSuccess"); // 返回xml中无isSuccess标签,即errorCode为null // if (errorCode == null) { // return false; // } if (errorCode != null) { errorCode = errorCode.replace("<![CDATA[", "").replaceAll("]]>", ""); } if (errorCode != null && errorCode.equalsIgnoreCase("1")) { errorInfo = StringUtil.getXmlValueByLabel(xml, "message"); // 成功 try { TribeAttentionBean MenuType_List_Son = null; XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser parser = factory.newPullParser(); parser.setInput(new StringReader(xml)); int eventType = parser.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { switch (eventType) { case XmlPullParser.START_DOCUMENT: break; case XmlPullParser.START_TAG: String tag = parser.getName(); if (tag.equalsIgnoreCase("List")) { list = new ArrayList<TribeAttentionBean>(); } else if (tag.equalsIgnoreCase("MenuType_List_Son")) { MenuType_List_Son = new TribeAttentionBean(); } else if (tag.equalsIgnoreCase("IsAttention")) { MenuType_List_Son.setIsAttention(parser.nextText()); } else if (tag.equalsIgnoreCase("TodayTopic")) { MenuType_List_Son.setTodayTopic(parser.nextText()); } else if (tag.equalsIgnoreCase("ID")) { MenuType_List_Son.setID(parser.nextText()); } else if (tag.equalsIgnoreCase("GuidStr")) { MenuType_List_Son.setGuidStr(parser.nextText()); } else if (tag.equalsIgnoreCase("FatherGuidStr")) { MenuType_List_Son.setFatherGuidStr(parser.nextText()); } else if (tag.equalsIgnoreCase("ImagePath")) { MenuType_List_Son.setImagePath(parser.nextText()); } else if (tag.equalsIgnoreCase("ImagePath_ico")) { MenuType_List_Son.setImagePath_ico(parser.nextText()); } else if (tag.equalsIgnoreCase("ImagePath_x")) { MenuType_List_Son.setImagePath_x(parser.nextText()); } else if (tag.equalsIgnoreCase("TypeName")) { MenuType_List_Son.setTypeName(parser.nextText()); } else if (tag.equalsIgnoreCase("Explanation")) { MenuType_List_Son.setExplanation(parser.nextText()); } else if (tag.equalsIgnoreCase("AttentionCount")) { MenuType_List_Son.setAttentionCount(parser.nextText()); } else if (tag.equalsIgnoreCase("AddTime")) { MenuType_List_Son.setAddTime(parser.nextText()); } else if (tag.equalsIgnoreCase("IsDelete")) { MenuType_List_Son.setIsDelete(parser.nextText()); } else if (tag.equalsIgnoreCase("DeleteCnvcAccount")) { MenuType_List_Son.setDeleteCnvcAccount(parser.nextText()); } else if (tag.equalsIgnoreCase("DeleteTime")) { MenuType_List_Son.setDeleteTime(parser.nextText()); } else if (tag.equalsIgnoreCase("DeleteContent")) { MenuType_List_Son.setDeleteContent(parser.nextText()); } else if (tag.equalsIgnoreCase("Sorting")) { MenuType_List_Son.setSorting(parser.nextText()); } else if (tag.equalsIgnoreCase("cnvcAccount")) { MenuType_List_Son.setCnvcAccount(parser.nextText()); } break; case XmlPullParser.END_TAG: String tagEnd = parser.getName(); if (tagEnd.equalsIgnoreCase("MenuType_List_Son")) { list.add(MenuType_List_Son); } break; } eventType = parser.next(); } } catch (Exception e) { e.printStackTrace(); } } else { errorInfo = StringUtil.getXmlValueByLabel(xml, "message"); errorInfo = errorInfo.replace("<![CDATA[", "").replaceAll("]]>", ""); if (errorInfo.trim().equals("")) { errorInfo = "服务器访问异常,稍后请重试!"; } } } else { errorInfo = "返回值为空"; } return true; }