How can I parse XML android?

后端 未结 1 727
谎友^
谎友^ 2021-01-13 02:36

I am having trouble in parsing my XML, I have tried many things.

I have xml like this.


  
1条回答
  •  执笔经年
    2021-01-13 03:38

    I have built my own parser for parsing this xml.

    Here is the code

    public class ProfileHome extends Activity {
    
        public String id="";
        public String text="";
        public ArrayListoption = new ArrayList();
        public String singleoption="";
    
        List q;
        private Questions question = new Questions();
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.profile_home);
            String payload = "";
            q = new ArrayList();
    
            if(payload.contains("question"))
                {
    
                    for(int i=0;i"))
                                                    {
                                                        ques.setOptions(option);
                                                        q.add(ques);
                                                        k=k+11;
                                                        break;
                                                    }
                                                //now get all options and their id's
                                                for(int j=k+11;j"))
                                                    {
                                                        option.add(singleoption);
                                                        singleoption="";
                                                        k=j+9;
                                                        break;
                                                    }else{
                                                        singleoption = singleoption +payload.substring(j,j+1);
                                                    }
    
                                                }
                                                }
                                            }
    
                                }
                            }
                        }
                }
    
    
            for(int i=0;i

    0 讨论(0)
提交回复
热议问题