开发者

problem in xml parsing and showing data in android application

开发者 https://www.devze.com 2023-03-18 20:10 出处:网络
I am developing an android application in which i have to parse the data from url and show in list.I have parsed url acc to sample code. I have extended the main class to the default handler class. an

I am developing an android application in which i have to parse the data from url and show in list.I have parsed url acc to sample code. I have extended the main class to the default handler class. and used main,start and end tag.I have parsed the url acc to below code

 HttpClient httpclient = new DefaultHttpClient();
     HttpPost httppost = new HttpPost("http://asia.vmsc.vmsplay.com/vmsc.asmx/GetCountries");

     // Add your data
      List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
         nameValuePairs.add(new BasicNameVa开发者_StackOverflowluePair("AccountId","vmsfree48jfwe83dwe8"));
         nameValuePairs.add(new BasicNameValuePair("Countries","US"));
        // nameValuePairs.add(new BasicNameValuePair("Language","en"));
         UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairs);
         httppost.setEntity(formEntity);

     // Execute HTTP Post Response
     HttpResponse response = httpclient.execute(httppost);
     InputStream is = response.getEntity().getContent(); 

     SAXParserFactory factory = SAXParserFactory.newInstance();
        SAXParser parser = factory.newSAXParser();
        XMLReader reader = parser.getXMLReader();
        MyXMLHandler myXMLHandler = new MyXMLHandler();
        reader.setContentHandler(myXMLHandler);
        reader.parse(new InputSource(is));          
        sitesList = MyXMLHandler.sitesList;

        countryname=new String[sitesList.getisocountrycode().size()];
        isocountrycode =new String[sitesList.getisocountrycode().size()];
        countrycode=new String[sitesList.getisocountrycode().size()];
        idd=new String[sitesList.getisocountrycode().size()];
        image=new String[sitesList.getisocountrycode().size()];
        image1=new String[sitesList.getisocountrycode().size()];


        for (int j = 0; j < sitesList.getisocountrycode().size(); j++) {
            countryname[j] = sitesList.getcountryname().get(j);
            System.out.println(" id "+sitesList.getcountryname().get(j));
            isocountrycode[j]=sitesList.getisocountrycode().get(j);
            System.out.println("title "+sitesList.getisocountrycode().get(j));
            countrycode[j] = sitesList.getcountrycode().get(j);
            System.out.println("desc "+sitesList.getcountrycode().get(j));
            idd[j] = sitesList.getProductcount().get(j);
            System.out.println("prociunt "+sitesList.getProductcount().get(j));
            image[j] = sitesList.getidd().get(j);
            System.out.println("image "+sitesList.getidd().get(j));
            System.out.println("image length  "+sitesList.getidd().get(j).length());
            image1[j] = sitesList.getImage1().get(j);
            System.out.println("image1 "+sitesList.getImage1().get(j));

But still I am not getting data that I have parsed ,,,

Can anyone tell where I have done wrong

Thanks in advance Tushar


it s not good thing to publish you confidentiality in public site. second thing is that you have to call this http://asia.vmsc.vmsplay.com/vmsc.asmx?op=GetCountries and pass your parameter then after http://asia.vmsc.vmsplay.com/vmsc.asmx/GetCountries then after you can get value from it. always keep habit to print responce in logcat and then you judge that " post this issue to any site or not".


What about changing your parameter "Countries" for "CountryCode". By the way it is not a good practice to publish your credentians on a public forum.

0

精彩评论

暂无评论...
验证码 换一张
取 消