当前位置: 首页 > 图文教程 > 网络编程 > Javascript > ext读取两种结构的xml的代码

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 359 ::
收藏到网摘: n/a

最近项目中要用ext读取xml,大家可以看下实现代码 <?xml version="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>
这一种比较常见 网上很多例子都是这种格式,我也写一下主要代码
var Info= Ext.data.Record.create([
'name', 'icon''
]);
reader=new Ext.data.XmlReader({
record: 'software',
id: 'name'
}, Info);
下面是另外一种格式的xml
<?xml version="1.0" encoding="utf-8" ?>
<softwarelist>
<software name="软件1" icon="1.gif" />
<software name="控件2" icon="2.gif" />
</softwarelist>
读取的主要代码
var Info= Ext.data.Record.create([
{name: 'name', mapping: '@name'},
{name: 'icon', mapping: '@icon' }
]);
reader=new Ext.data.XmlReader({
record: 'software',
id: 'name'
}, Info);
ext的帮助文档里 也只有第一种的写法,第二种是我试了快两个小时才找到的方法,现在还不知道原因,但是能用。希望高人能给解释一下。晚生我洗耳恭听了!