本文介绍了安卓:XmlpullParser异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被困了一个问题,在我的程序我正在xmlpullparser例外,我瞪大眼睛,但因为我是新到Android我无法理解如何解决这个问题。我纠正我的程序仍然有很多我不能,有人帮我解决这个

我使用WSDL,KSOAP1.2。

在此先感谢....!

下面是我的code

 公共无效寄存器(){
    Log.v(TAG,试图登录);
      的EditText etxt_user =(EditText上)findViewById(R.id.regetfirstname);
      的EditText etxt_pass =(EditText上)findViewById(R.id.regetlastname);
      的EditText etxt_dob =(EditText上)findViewById(R.id.regetdob);
      的EditText etxt_email =(EditText上)findViewById(R.id.regetemail);
      的EditText etxt_password =(EditText上)findViewById(R.id.regetpwd);
      的EditText etxt_confirmpassword =(EditText上)findViewById(R.id.regetrepwd);
      的EditText etxt_mobno =(EditText上)findViewById(R.id.regetmobno);
       最终按钮regmalebtn =(按钮)findViewById(R.id.regmalebtn);
       按钮regfemalebtn =(按钮)findViewById(R.id.regfemalebtn);
    //字符串DEVICEID = NULL;
      。字符串FNAME = etxt_user.getText()的toString();
      。字符串LNAME = etxt_pass.getText()的toString();
      。字符串DOB = etxt_dob.getText()的toString();
      弦接触= etxt_mobno.getText()的toString()。
      字符串密码;
      串confirmpassword;
      。字符串email = etxt_email.getText()的toString();
      。密码= etxt_password.getText()的toString();
      confirmpassword = etxt_confirmpassword.getText()的toString()。     最后SoapObject要求=新SoapObject空间(namespace,METHOD_NAME);
    SoapSerializationEnvelope的SoapEnvelope =新SoapSerializationEnvelope(SoapEnvelope.VER11);
    soapEnvelope.dotNet = TRUE;
    soapEnvelope.setOutputSoapObject(请求);
    HttpTransportSE AHT =新HttpTransportSE(URL);
    尝试{   //布尔pstatus = FALSE;
    如果(confirmpassword = NULL&放大器;!&放大器;密码!= NULL)
   {
   如果(password.equals(confirmpassword))
   {
        request.addProperty(密码,密码);   }
 }
    regmalebtn.setOnClickListener(新OnClickListener(){        @覆盖
        公共无效的onClick(视图v){
            // TODO自动生成方法存根
           //字符串性别= regmalebtn.getText()的toString()。             字符串性别;
             性别=((按钮)findViewById(R.id.regmalebtn))的getText()的toString()。
            gender.equals(男性);
            request.addProperty(性别,性别等);
        }
    });
     regfemalebtn.setOnClickListener(新OnClickListener(){        @覆盖
        公共无效的onClick(视图v){
            // TODO自动生成方法存根
           //字符串性别= regmalebtn.getText()的toString()。
           // request.addProperty(性别,性别等);
             字符串性别;
             性别=((按钮)findViewById(R.id.regfemalebtn))的getText()的toString()。
            gender.equals(女);
            request.addProperty(性别,性别等);
        }
    });     request.addProperty(邮件,邮件);
    request.addProperty(联系,联系方式);
    request.addProperty(其中fname,FNAME);
    request.addProperty(L-NAME,LNAME);    request.addProperty(出生日期,DOB);
    //request.addProperty(\"password,密码);
    request.addProperty(纬度,76);
    request.addProperty(经度,82);
    request.addProperty(DEVICE_ID,12345);        aht.setXmlVersionTag(&下; XML版本= \\1.0 \\编码= \\UTF-8 \\>);
        aht.call(SOAP_ACTION,的SoapEnvelope);
      // SoapObject结果=(SoapObject)soapEnvelope.getResponse();
        SoapObject resultsRequestSOAP =(SoapObject)soapEnvelope.bodyIn;
        Log.v(TAG,将String.valueOf(resultsRequestSOAP));
        //字符串resultData;
    // resultData = request.getProperty(0)的ToString();
    }赶上(例外五){        e.printStackTrace();
    }
}}

以上是logcat的消息

解决方案
public static void getAllXML(String url) throws
XmlPullParserException, IOException, URISyntaxException{
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser parser = factory.newPullParser();
parser.setInput(new InputStreamReader(getUrlData(url)));
XmlUtils.beginDocument(parser,"results");
int eventType = parser.getEventType();
do{
  XmlUtils.nextElement(parser);
  parser.next();
  eventType = parser.getEventType();
  if(eventType == XmlPullParser.TEXT){
  Log.d("test",parser.getText());
}
} while (eventType != XmlPullParser.END_DOCUMENT) ;
}
public InputStream getUrlData(String url)
throws URISyntaxException, ClientProtocolException, IOException {
 DefaultHttpClient client = new DefaultHttpClient();
HttpGet method = new HttpGet(new URI(url));
  HttpResponse res = client.execute(method);
return  res.getEntity().getContent();
}

这篇关于安卓:XmlpullParser异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 00:45