-
12 Jan 2011 3:33 AM #1
Please help
Please help
How do i read this xml i tried using the foll but it doesnt work
Ext.regModel('HitrateRegel',{
fields:[
{ name: 'title', type: 'string', mapping:'@title'},
{ name: 'catId', type: 'string', mapping:'@catId'}
]
});
Nested XML
Code:<?xml version="1.0" encoding="ISO8859-1" ?> <categories> <category> <name catId="106" title="Belay Devices"/> <name catId="108" title="Belay Devices Inside"/> </category> </categories>
-
12 Jan 2011 3:40 AM #2
You have to provide more information about the code you use to read your xml.
I can't understand how you are trying to read it because I only see you declared a model and nothing else.
If you can post the full code or part of it.Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
12 Jan 2011 3:43 AM #3
Code
Code
Hello Here is the code
Here is the XMLCode:Ext.regModel('HitrateRegel',{ fields:[ { name: 'title', type: 'string', mapping:'@title'}, { name: 'catId', type: 'string', mapping:'@catId'} ] }); var HitrateStore = new Ext.data.Store({ model: 'HitrateRegel', proxy: { type: 'ajax', url: 'data.xml', reader: { type: 'xml', record:'category' } }, listeners: { load: function(store, records, success) { console.log(store); console.log(records); console.log(success); } } }); testtpl = '<div class="contact"><table><tr><td><strong>{title}</strong><br>{catId}</td></tr></table></div>'; topics = new Ext.List({ tpl:'<tpl for=".">'+ testtpl +'</tpl>', xtype: 'list', cls: 'demo-list', itemSelector: 'div.contact', iconCls: 'topicIcon', title:'Topics', store: HitrateStore, listeners: { beforeactivate: function(c) { HitrateStore.load(); } } });
Code:<?xml version="1.0" encoding="ISO8859-1" ?> <categories> <category> <name catId="106" title="Belay Devices"/> <name catId="108" title="Belay Devices Inside"/> </category> </categories>
-
12 Jan 2011 3:57 AM #4
-
12 Jan 2011 5:05 AM #5Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
In your reader, set the root: "categories"
Code:... reader: { type: 'xml', root: "categories", record:'category' } ...Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
12 Jan 2011 5:11 AM #6
I changed it but its not reading it, is the following mapping ok ? Also is root: "categories" correct or root: 'categories', i tried with both but its not working
{ name: 'title', type: 'string', mapping:'@title'},
{ name: 'catId', type: 'string', mapping:'@catId'}
-
12 Jan 2011 5:16 AM #7Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
double-quotes or single-quotes don't matter, I just prefer it personally. Most prefer single-quotes.
try your fields without the mapping field. Does it work then?
Code:{ name: 'title', type: 'string'}, { name: 'catId', type: 'string'}Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
12 Jan 2011 5:19 AM #8
No tried with following, doesnt work
Code:Ext.regModel('HitrateRegel',{ fields:[ { name: 'title', type: 'string'}, { name: 'catId', type: 'string'} ] }); var HitrateStore = new Ext.data.Store({ model: 'HitrateRegel', proxy: { type: 'ajax', url: 'data.xml', reader: { type: 'xml', root: "categories", record:'category' }
-
12 Jan 2011 6:02 AM #9
What's the error you get if you include sencha-touch-debug.js instead sencha-touch.js?
Did you get a loading error like "Result of expression 'records' [undefined] is not an object" or what else?
Anyway check even your list configuration:
You set a tpl config param in the code you posted but you have to use itemTpl.
Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
12 Jan 2011 6:20 AM #10
This is the error i see when i use
sencha-touch-debug.js
This is the error i see when i use sencha-touch-debug.js
Code:Uncaught Error: Ext.List: itemTpl is a required configuration. /sencha-touch-debug.js:23116Uncaught Error: Ext.List: itemTpl is a required configuration. /search.js:2Uncaught TypeError: undefined is not a function /sencha-touch-debug.js:23116Uncaught Error: Ext.List: itemTpl is a required configuration.


Reply With Quote