How to parse xml data getting from web service?

  1. himanshu19890
    himanshu19890
    Hello friends,
    How are you buddy.I have one more query about sencha touch.I am trying to parse ASP.NETwebservice response(which is in xml format),but no success get yet.The response holds the following xml data:-

    Code:
    <UsersDataModel>
             <userID>58028f37-1486-46bc-8c74-225ff7097474</userID>
              <userName>survaa</userName>
              <password>survaa</password>
              <lastLoginDate>2010-02-15T00:00:00</lastLoginDate>
              <userGroupID>44ad88bb-7e2d-4fbf-80e1-9e1f1a6f4ddc</userGroupID>
              <userFirstName>SUR</userFirstName><userMiddleName/>
              <userLastName>SURVEYOR</userLastName>
              <clientID>00000000-0000-0000-0000-000000000000</clientID>
              <clientObj xsi:nil="true"/>
              <userGroupObj>
                     <userGroupID>44ad88bb-7e2d-4fbf-80e1-9e1f1a6f4ddc</userGroupID>
                     <groupName>SURVEYOR</groupName>
               </userGroupObj>                 
              <formPermList>INRD1000^CODE0000^CAIE1111R1111^CHPA1111^INDE1000</formPermList>
              <salutation>0</salutation>
              <numberOfSurveys>0</numberOfSurveys>
              <addressDetailsObj xsi:nil="true"/>         
             <servProvID>d0e8f20a-5293-4a29-9094-28141f63fc78</servProvID><servProvObj xsi:nil="true"/>
    </UsersDataModel> 


    I want to parse the response object.I have checked few forums but did'nt get satisfactory answer.Then i got this http://stackoverflow.com/questions/6...h-sencha-touch and tried its solution like the below.

    Code:
    <!DOCTYPE html>
    <html>
        <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <title>XML Example</title>
            <link rel="stylesheet" type="text/css" href="touch/sencha-touch.css"/>
    		<script type="text/javascript" src="touch/sencha-touch.js"></script>
    		<script type="text/javascript" src="phonegap-1.4.1.js"></script>
    		<script type="text/javascript" src="ext-all/ext-all.js"></script> 
    		<script type="text/javascript" src="ext-all/ext-all-debug.js"></script> 
            <script type="text/javascript">
                new Ext.Application({
                    name: 'xmlexample',
                    launch: function(){
                        Ext.regModel('UsersDataModel', {
                            fields: ['userID','userName','password','lastLoginDate'] //etc...
                        });
    
    
                        this.stores.profiles = new Ext.data.Store({
                            model: 'UsersDataModel',
                            autoLoad:true,
                            implicitIncludes: true,
                            proxy: {
                                type: 'ajax',
                                url : 'http://192.168.1.15/DemoInspect/Serv...thenticateUser',
                                reader: {
                                    type  : 'xml',
                                    root  : 'UsersDataModel',
                                    record: 'UsersDataModel'
                                }
                            }
                        });
                    var productTpl = new Ext.XTemplate(
                        '<tpl for=".">',
                            '<div class="data">{userID}</div>',
                            '<div class="data">{userName}</div>',
                    		'<div class="data">{password}</div>',
                            '<div class="data">{lastLoginDate}</div>',
                        '</tpl>'
                    );    
                    new Ext.Panel({
                        fullscreen: true,
                        items: new Ext.DataView({
                            store: this.stores.profiles,
                            tpl: productTpl,
                            itemSelector: 'product-selected'
                            //other config goes here
                        })
                    });
                }
            });        
            </script>
        </head>
        <body>
        </body>
    </html>



    But didn't get success to parse the xml data.I am getting the "Cannot read property 'length' of undefined in sencha-touch.js" error while running the above code.Please help me to get rid of the problem .Thanx in advance.
  2. abinkoshy
    abinkoshy
    can any1 pls help me out with a sample code for extracting data from a json and diplaying it in a list box and storing it
Results 1 to 2 of 2