我有以下 XML 结构,我想根据Tab、Topic、SubTopic 和 Screen动态获取 Fields 标记值;这可能吗?请让我知道适当的解决方案。
XML结构:
<?xml version="1.0" encoding="utf-8"?>
<Settings>
<ABC TYPE="Tab">
<Trans TYPE="Topic">
<Rpt TYPE="SubTopic">
<File TYPE="Screen">
<Fields>
<Tin>10</Tin>
<Pin>8</Pin>
</Fields>
</File>
</Rpt>
</Trans>
</ABC>
<XYZ TYPE="Tab">
<Trans TYPE="Topic">
<Rpt TYPE="SubTopic">
<File TYPE="Screen">
<Fields>
<Tin>10</Tin>
<Pin>8</Pin>
</Fields>
</File>
</Rpt>
</Trans>
</XYZ>
</Settings>
模型结构:
Ext.define('MyApp.model.ScreenValidation', {
extend: 'Ext.data.Model',
config: {
fields: [
{
name: 'Tin',
type: 'string'
},
{
name: 'Pin',
type: 'string'
}
]
}
});
XMLStore 结构器:
Ext.define('MyApp.store.ScreenValidation', {
extend: 'Ext.data.Store',
requires: [
'MyApp.model.ScreenValidation'
],
config: {
autoLoad: true,
model: 'MyApp.model.ScreenValidation',
storeId: 'ScreenValidation',
proxy: {
type: 'ajax',
url: 'ScreenValidation.xml',
reader: {
type: 'xml',
record: 'Fields'
}
}
}
});
任何帮助表示赞赏!