关闭

android xml解析

304人阅读 评论(0) 收藏 举报

public class CustomHandler extends DefaultHandler
{
 public Object getResult()
 {
  return null;
 }
}

 

 

 

public class AdvsHandler extends CustomHandler
{

 private AdvsInfo mAdvsInfo = new AdvsInfo();

 private String mLocalName;

 public void startElement(String uri, String localName, String qName, Attributes attributes)
   throws SAXException
 {
  mLocalName = localName;
 }

 public void endElement(String uri, String localName, String qName) throws SAXException
 {
  mLocalName = "default";
 }

 public void characters(char[] ch, int start, int length) throws SAXException
 {
  String value = new String(ch, start, length);
  if (null == value || value.trim().length() == 0)
  {
   return;
  }

  if ("resultCode".equalsIgnoreCase(mLocalName))
  {
   mAdvsInfo.setResultCode(value);
  }
  else if ("pictureUrl".equalsIgnoreCase(mLocalName))
  {
   mAdvsInfo.setPictureUrl(value);
  }
  else if ("adLinkUrl".equalsIgnoreCase(mLocalName))
  {
   mAdvsInfo.setAdLinkUrl(value);
  }
 }

 public Object getResult()
 {
  return mAdvsInfo;
 }
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:41673次
    • 积分:675
    • 等级:
    • 排名:千里之外
    • 原创:25篇
    • 转载:0篇
    • 译文:0篇
    • 评论:6条
    最新评论