以下代码抛出异常

时间:2014-09-15 10:17:53

标签: android

我的InputStream抛出以下代码的异常 我无法找到我从早上开始调试并尝试使用它的错误

错误 - org.xml.sax.SAXParseException:expected:/ center read:form(position:END_TAG @ 24:855 in java.io.InputStreamReader@526ea7c0)请帮忙。


            public class MainActivity extends Activity {

            Element RootElement;
            Element xmlElement;
            Context context;
            TextView textView1;
            String url = "http://www.androidbegin.com", s;
            ProgressDialog mProgressDialog;
            String UrlLink = "http://postimg.org/gallery/5y7ulm9o/b2f8235e/";

            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_main);

                textView1 = (TextView) findViewById(R.id.textView1);
                context = this;

                Gethtml Ght = new Gethtml();
                Ght.execute();
            }

            public class Gethtml extends AsyncTask {
                ProgressDialog dialog;

                @Override
                protected void onPreExecute() {
                    // TODO Auto-generated method stub
                    super.onPreExecute();
                    dialog = new ProgressDialog(context);
                    dialog.setTitle("Loading");
                    dialog.setMessage("Html....");
                    dialog.show();
                }

                @Override
                protected Object doInBackground(Object... params) {
                    try {
                    HttpClient client = new DefaultHttpClient();
                    HttpGet request = new HttpGet(UrlLink);
                    HttpResponse response = client.execute(request);
                    StatusLine line = response.getStatusLine();
                    int statuscode = line.getStatusCode();
                    if (statuscode != 200) {
                        return null;
                    }
                     InputStream IpStream=response.getEntity().getContent();
  /*throws error---->*/processXML(IpStream);
                    }
                    catch(Exception e){
                        Log.v("Error",e.toString());
                    }

                    return null;
                }
        public void processXML(InputStream IS)throws Exception{
            DocumentBuilderFactory DBF=DocumentBuilderFactory.newInstance();
            DocumentBuilder DB=DBF.newDocumentBuilder();
            org.w3c.dom.Document xmlDocument=DB.parse(IS);
            Element RootElement=xmlDocument.getDocumentElement();

        }
                @Override
                protected void onPostExecute(Object result) {
                    dialog.dismiss();
                    Log.v("VIVZ",RootElement.getTagName());
                 Toast.makeText(MainActivity.this, "text", Toast.LENGTH_SHORT).show();
                    textView1.setText(s);
                     //super.onPostExecute(result);
                }

            }

        }

Logcat

enter image description here

0 个答案:

没有答案