zl程序教程

您现在的位置是:首页 >  前端

当前栏目

ext读取两种结构的xml的代码

XML代码 结构 读取 两种 Ext
2023-06-13 09:14:06 时间
<?xmlversion="1.0"encoding="utf-8"?>
<list>
<software>
<name>软件1</name>
<icon>1.gif</icon>
</software>
<software>
<name>控件2</name>
<icon>2.gif</icon>
</software>
</list>
这一种比较常见网上很多例子都是这种格式,我也写一下主要代码
varInfo=Ext.data.Record.create([
"name","icon""
]);
reader=newExt.data.XmlReader({
record:"software",
id:"name"
},Info);
下面是另外一种格式的xml
<?xmlversion="1.0"encoding="utf-8"?>
<softwarelist>
<softwarename="软件1"icon="1.gif"/>
<softwarename="控件2"icon="2.gif"/>
</softwarelist>
读取的主要代码
varInfo=Ext.data.Record.create([
{name:"name",mapping:"@name"},
{name:"icon",mapping:"@icon"}
]);
reader=newExt.data.XmlReader({
record:"software",
id:"name"
},Info);
ext的帮助文档里也只有第一种的写法,第二种是我试了快两个小时才找到的方法,现在还不知道原因,但是能用。希望高人能给解释一下。晚生我洗耳恭听了!