EXT读取XML数据

先来个数据
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->  1 <? xml version="1.0"  encoding="utf-8" ?>
 2 < items >
 3      < item >
 4          < id > 1 </ id >
 5          < name > DaiXiaosheng </ name >
 6          < sex > men </ sex >
 7      </ item >
 8      < item >
 9          < id > 2 </ id >
10          < name > Dai </ name >
11          < sex > men </ sex >
12      </ item >
13      < item >
14          < id > 3 </ id >
15          < name > xiaoshengDai </ name >
16          < sex > men </ sex >
17      </ item >
18      < item >
19          < id > 4 </ id >
20          < name > xiao </ name >
21          < sex > men </ sex >
22      </ item >
23 </ items >

再来个类
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->  1 ExpandedBlockStart.gif ContractedBlock.gif /**/ /*XmlGrid samples*/
 2
 3 ExpandedBlockStart.gifContractedBlock.gifXmlGrid  =   function (config) {
 4ExpandedSubBlockStart.gifContractedSubBlock.gif    config = config || {};
 5    
 6    this.cm = new Ext.grid.ColumnModel([
 7ExpandedSubBlockStart.gifContractedSubBlock.gif        { header:'id' , dataIndex:'id' },
 8ExpandedSubBlockStart.gifContractedSubBlock.gif        { header:'name' , dataIndex:'name' },
 9ExpandedSubBlockStart.gifContractedSubBlock.gif        { header:'sex' , dataIndex:'sex' }
10    ]);
11    
12ExpandedSubBlockStart.gifContractedSubBlock.gif    this.store = new Ext.data.Store({        
13        url:'data.xml',
14ExpandedSubBlockStart.gifContractedSubBlock.gif        reader: new Ext.data.XmlReader({
15            record:'item',
16            id:'id',
17            totalRecords:'@total'
18            
19        }
,[
20ExpandedSubBlockStart.gifContractedSubBlock.gif            {name:'id',mapping:'id'},
21ExpandedSubBlockStart.gifContractedSubBlock.gif            {name:'name',mapping:'name'},
22ExpandedSubBlockStart.gifContractedSubBlock.gif            {name:'sex',mapping:'sex'}            
23        ])    
24    }
);
25    
26    this.store.load();
27    
28ExpandedSubBlockStart.gifContractedSubBlock.gif    Ext.applyIf(config,{
29        width:400,
30        height:200,
31        frame:true,
32        border:true
33    }
);
34    
35    XmlGrid.superclass.constructor.call(this,config);
36}

37
38 ExpandedBlockStart.gifContractedBlock.gifExt.extend(XmlGrid,Ext.grid.GridPanel, {} );
39
40
41 ExpandedBlockStart.gifContractedBlock.gifExt.onReady( function () {
42    var xmlgrid = new XmlGrid();
43    xmlgrid.render('xml_main')
44}
);

渲染页面
ContractedBlock.gif ExpandedBlockStart.gif Code
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><%@ page language="java"  pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  
<head>
    
<title>JsonGrid</title>    
    
<link rel="stylesheet" type="text/css" href="../extjs/resources/css/ext-all.css">
    
<script type="text/javascript" src="../extjs/adapter/ext/ext-base.js"></script>
    
<script type="text/javascript" src="../extjs/ext-all.js"></script>
    
<script type="text/javascript" src="../grid/XmlGrid.js"></script>
  
</head>  
  
<body> 
    
<div id="xml_main"></div>
  
</body>
</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值