-
8 Jun 2011 11:49 AM #1
Reading complex XML using XMLReader.
Reading complex XML using XMLReader.
Hello All,
I am new to sencha touch. I know how to read simple XML .I want to read complex XML response in my application.The XML looks like below.
<LicenseKey licensedTo="Sagar">
<DefaultProductType>
<ProductType name="SINGLE" code="INV"/>
<ProductType name="COUPLE" code="INV"/>
<ProductType name="GROUP" code="GRP"/>
<ProductType name="VOLUNTARY" code="VOL"/>
</DefaultProductType>
<Products>
<Product name="Sagar1" code="Bedford">
<States>
<State name="Arizona" code="AZ"/>
<State name="California" code="CA"/>
<State name="Colorado" code="CO"/>
<State name="Connecticut" code="CT"/>
<State name="Florida" code="FL"/>
<State name="Hawaii" code="HI"/>
<State name="Illinois" code="IL"/>
<State name="Indiana" code="IN"/>
<State name="Maryland" code="MD"/>
<State name="Massachusetts" code="MA"/>
<State name="Michigan" code="MI"/>
<State name="Nevada" code="NV"/>
<State name="New Hampshire" code="NH"/>
<State name="New Jersey" code="NJ"/>
<State name="New York" code="NY">
<excludedProductType>
<excludedProductType name="Group" code="GRP"/>
<excludedProductType name="Voluntary" code="VOL"/>
</excludedProductType>
</State>
<State name="Ohio" code="OH"/>
<State name="Virginia" code="VA"/>
</States>
</Product>
<Product name="Sagar2" code="Arlington">
<States>
<State name="Arizona" code="AZ"/>
<State name="California" code="CA"/>
<State name="Colorado" code="CO"/>
<State name="Connecticut" code="CT"/>
<State name="Florida" code="FL"/>
<State name="Hawaii" code="HI"/>
<State name="Illinois" code="IL"/>
<State name="Indiana" code="IN"/>
<State name="Maryland" code="MD"/>
<State name="Massachusetts" code="MA"/>
<State name="Michigan" code="MI"/>
<State name="Nevada" code="NV"/>
<State name="New Hampshire" code="NH"/>
<State name="New Jersey" code="NJ"/>
<State name="Ohio" code="OH"/>
<State name="Virginia" code="VA"/>
</States>
</Product>
</Products>
</LicenseKey>
Can anyone guide me with this problem?
Thanks!
-
9 Jun 2011 1:53 PM #2
Here is model which I wrote for my XML. I am not able to verify wheather my code is reading XML or not?
Code:<!DOCTYPE HTML> <html> <head> <title>Touch Test</title> <script type="text/javascript"> Ext.setup({ glossOnIcon: false, onReady: function() { Ext.regModel('LicenseKey', { fields: [ 'licensedTo'], // associations:[ // {type:'hasMany',model:'DefaultQuoteTypes',name:'DefaultQuoteType'}, // {type:'hasMany',model:'Products',name:'Product'} // ] validations:[ {type: 'presence', field: 'licensedTo'}, ] }); Ext.regModel('DefaultQuoteTypes', { fields: [], hasMany:{model:'QuoteType',name:'QuoteTypes'}, belongTo:{model:'LicenseKey',name:'LicenseKeys'} }); Ext.regModel('QuoteType', { fields: ['name','code'], belongTo:{model:'DefaultQuoteTypes',name:'DefaultQuoteType'} }); Ext.regModel('Products', { fields: [], hasMany:{model:'Product1',name:'Product1s'}, belongTo:{model:'LicenseKey',name:'LicenseKeys'} }); Ext.regModel('Product1', { fields: ['name','code'], //hasMany:{model:'States',name:'States'}, belongTo:{model:'Products',name:'Product'} }); Ext.regModel('States', { fields: [], hasMany:{model:'State',name:'State'}, belongTo:{model:'Product1',name:'Product1s'} }); Ext.regModel('State', { fields: ['name','code'], //hasMany:{model:'excludedQuoteType',name:'excludedQuoteTypes'}, belongTo:{model:'States',name:'States'} }); Ext.regModel('excludedQuoteType', { fields: ['name','code'], belongTo:{model:'State',name:'State'} }); var login=new Ext.data.Store({ model:'LicenseKey', autoLoad:true, method:GET, proxy:{ type: 'ajax', url: reader:{ type:'xml', record:'LicenseKey' } } }); login.load({ callback:function(){ var user=login.first(); var errors = login.validate(); console.log("Orders for " + user.get('licensedTo') + ":") } }); </script> </head> <body> </body> </html>
-
23 Jun 2011 3:05 PM #3
I have a similar post I made back in May. Still waiting for a Sencha employee to comment.
Sadly, i am beginning to think that they only respond to those who pay for support. Even though this seems to be to be a bug. Nested Models just flat out don't work in 4.0 :-(
http://www.sencha.com/forum/showthre...riter&p=616813


Reply With Quote