1. #1
    Sencha User
    Join Date
    Mar 2013
    Posts
    9
    Vote Rating
    0
    qiang lai is on a distinguished road

      0  

    Default Unanswered: problem in reading xml

    Unanswered: problem in reading xml


    Hello,everyone!
    I use store,model,proxy to read xml and meet a problem.
    my xml:
    <?xml version="1.0" encoding="utf-8"?>
    Code:
    <School>
        <Class>
            <Student>
                <StudentInfo>
                    <Code>1000001</Code>
                    <Name>qiang lai</Name>
                    <Sex>M</Sex>
                    <BirthDay>19860828</BirthDay>
                    <Age>27</Age>
                </StudentInfo>
                <Comment>comment:111</Comment>
                <StudentStatus>status:111</StudentStatus>
                <Parties>
                    <Party>
                        <PartyName>PartyName111-1</PartyName>
                        <PartyStatus>PartyStatus111-1</PartyStatus>
                        <CommentOne>CommentOne111-1</CommentOne>
                        <CommentTwo>CommentTwo111-1</CommentTwo>
                    </Party>
                    <Party>
                       <PartyName>PartyName111-2</PartyName>
                        <PartyStatus>PartyStatus111-2</PartyStatus>
                        <CommentOne>CommentOne111-2</CommentOne>
                        <CommentTwo>CommentTwo111-2</CommentTwo>
                    </Party>
                </Parties>
            </Student>
            <Student>
                <StudentInfo>
                    <Code>1000002</Code>
                    <Name>jj lai </Name>
                    <Sex>FM</Sex>
                    <BirthDay>19870828</BirthDay>
                    <Age>26</Age>
                </StudentInfo>
                <Comment>comment:222</Comment>
                <StudentStatus>status:222</StudentStatus>
                <Parties>
                    <Party>
                        <PartyName>PartyName222-1</PartyName>
                        <PartyStatus>PartyStatus222-1</PartyStatus>
                        <CommentOne>CommentOne222-1</CommentOne>
                        <CommentTwo>CommentTwo222-1</CommentTwo>
                    </Party>
                    <Party>
                       <PartyName>PartyName222-2</PartyName>
                        <PartyStatus>PartyStatus222-2</PartyStatus>
                        <CommentOne>CommentOne222-2</CommentOne>
                        <CommentTwo>CommentTwo222-2</CommentTwo>
                    </Party>
                    <Party>
                       <PartyName>PartyName333-2</PartyName>
                        <PartyStatus>PartyStatus333-2</PartyStatus>
                        <CommentOne>CommentOne333-2</CommentOne>
                        <CommentTwo>CommentTwo333-2</CommentTwo>
                    </Party>
                </Parties>
            </Student>
        </Class>
    </School>
    and the js code reading xml:
    Code:
     
    readXml:function(){
     Ext.define('School',{
          extend:'Ext.data.Model',
          config:{
        proxy: {
         type: 'ajax',
         url : 'xmldatafolder/StudentContent.xml',
         reader: {
          type  : 'xml',
          record: 'School'
         }
        },
           hasMany:{
            model:'Student',
            name :'getStudents',
            associationKey: 'Student'
           },
          }
      });
      
     Ext.define('Student',{
          extend:'Ext.data.Model',
          config:{
           fields: ['Comment', 'StudentStatus','Code', 'Name', 'Sex', 'BirthDay','Age'],
           belongsTo:['School'],
           hasMany:{
            model:'Party',
            name :'getPartys',
            associationKey: 'Parties'
           },
              proxy: {
               type:'ajax',
               url : 'xmldatafolder/StudentContent.xml',
               reader: {
                type: 'xml',
                root: 'Class',
                record: 'StudentInfo'
               }
              }
          }
      });
     Ext.define('Party',{
          extend:'Ext.data.Model',
          config:{
              fields:['PartyName', 'PartyStatus', 'CommentOne', 'CommentTwo'],
              belongsTo:['Student'],
              proxy: {
               type:'ajax',
               url : 'xmldatafolder/StudentContent.xml',
               reader: {
                type: 'xml',
                root: 'Parties',
                record: 'Section'
               }
              }
          }
      });
     OutPatients.load(1, {
       success: function(outpatient) {
        var res = outpatient.getStudents();
        res.load({
         callback:function(records, operation, success){
          for(var i = 0; i < records.length; i++){
           var result = records[i];
           console.log("Comment: " + result.get('Comment'));
           console.log("StudentStatus: " + result.get('StudentStatus'));
           console.log("Code: " + result.get('Code'));
           console.log("Name: " + result.get('Name'));
           console.log("Sex: " + result.get('Sex'));
           console.log("BirthDay: " + result.get('BirthDay'));
           console.log("Age: " + result.get('Age'));
           console.log("--------------------------------------");
           var sec = result.getPartys();
           sec.load({
            callback:function(cos, operation, success){
              for(var j = 0; j < cos.length; j++){
               var ret = cos[j];
               console.log("PartyName: " + ret.get('PartyName'));
               console.log("PartyStatus: " + ret.get('PartyStatus'));
               console.log("CommentOne: " + ret.get('CommentOne'));
               console.log("CommentTwo: " + ret.get('CommentTwo'));
               console.log("--------------------------------------");
              }
            }
           });
          }
         }
        });
       }
      });
    },
    The problems is:When I use the config"root: 'Parties'," in the model "'Party'", for each studnet I will only get parties infomation in the first xml tags "parties",info in other "parties' tags never appear,
    and When I delete the config"root: 'Parties'," in the model "'Party'", for each studenti get all infomation in all "parties" tags,but not info of the current student.
    How to get the information only of the current student.
    can you help me?
    thanks in advance.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,677
    Answers
    3355
    Vote Rating
    749
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    What is OutPatients?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Mar 2013
    Posts
    9
    Vote Rating
    0
    qiang lai is on a distinguished road

      0  

    Default


    "OutPatients" should be "School" .

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar