< type id = "3" val = "0"> 257411
If anyone can Provide a suitable “mapping”, I would appreciate it
XML data:
302221
257411
28213
8645
3664
2246< /type>
1124
918
Model Basic
Ext.define( “ap3.model.Basic”,{
extend: “Ext.data.Model” ,
config: {
fields: [
{name:'id', mapping:'@id'},
{name :'name', mapping: ' @name'},
{name:'number', mapping:'number'}
],
associations: [
{
type:'hasMany',
model:'apv3.model.Type',
associationKey:'types'
}]
}
});
Model type
Ext.define( “ap3.model.Type”,{
extend: “Ext.data.Model”,
config: {
fields: [
{name:'id', mapping:'@id'},
{name:'val', mapping: '@val'},
{name:'type', mapping:'type'}
],
proxy: {
type: 'memory',
reader: {
type:'xml',
record:'type'
}
}
}
< p>});
{name:'id', mapping:'@id'},
{name:'name', mapping:'@name'},
{name:'number', mapping: function (node) {
return (node.firstChild? node.firstChild.nodeValue: null );
}}
I use nested XML and use’hasMany’ to parse it. If anyone can tell me how to read the node’
< type id = "3" val ="0"> 257411
If someone can provide a suitable “mapping”, I would be very grateful.
XML data:
302221
257411
28213 < br />8645
3664
2246
1124
918
Model Basic
Ext.define( “ap3.model.Basic”,{
extend: “Ext.data.M odel”,
config: {
fields: [
{name:'id', mapping:'@id'},
{name:'name', mapping:'@name'},
{name:'number', mapping:'number'}
],
associations: [
{
type:'hasMany',
model:'apv3.model.Type',
associationKey:'types'
} ]
}
});
Model type
Ext.define( “ap3.model.Type”,{
extend: “Ext.data .Model”,
config: {
fields: [
{name:'id', mapping:'@id'},
{name:'val', mapping:'@val'},
{name:'type', mapping:'type'}
],
proxy: {
type:'memory',
reader: {
type:'xml',
record:'type'
}
}
}
});
p>
“mapping” also accepts a function:
{name:'id', mapping:'@id' },
{name:'name', mapping:'@name'},
{name:'number', mapping: function (node) {
return (node.firstChild? node .firstChild.nodeValue: null);
}}