ext 成功解析xml

    技术2025-02-13  12

    <script type="text/javascript">

      Ext.onReady(function(){

     

        var store=new Ext.data.Store({     

          url:'GridData.xml',

          reader:new Ext.data.XmlReader(

            {record:'Item'},        

            ["ASIN","Author","Manufacturer","ProductGroup","Title"])

        });

     

        var grid=new Ext.grid.GridPanel({

          store:store,

          columns:[

            {id:"ASIN",header:"出版号",width:120,dataIndex:'ASIN',sortable:true},

            {header:"作者",width:120,dataIndex:'Author',sortable:true},

            {header:"书名",width:180,dataIndex:'Title',sortable:true},

            {header:"制作商",width:115,dataIndex:'Manufacturer',sortable:false},

            {header:"产品组",width:100,dataIndex:'ProductGroup',sortable:false}],

          renderTo:'example-grid',

          viewConfig:{columnsText:'显示列',sortAscText:'升序',sortDescText:'降序'},

          width:640,

          height:100

        });

        store.load();

      });

    </script>

     </head>

    <body>

    <div id="example-grid"></div>

    </body>

    </html>

     

    --------------------------------------------GridData.xml:

    <?xml version="1.0" encoding="UTF-8"?>

    <Data>

     <Items> 

      <TotalResults>203</TotalResults>

      <TotalPages>21</TotalPages>

      <Item>

       <ASIN>0446355453</ASIN>  

       <Author>Jimmy.Yang</Author>

       <Manufacturer>WarnerBooks</Manufacturer>

       <ProductGroup>Book</ProductGroup>

       <Title>MasteroftheGame</Title>   

      </Item>

      <Item>

       <ASIN>0446613657</ASIN>     

       <Author>SidneySheldon</Author>

       <Manufacturer>WarnerBooks</Manufacturer>

       <ProductGroup>Book</ProductGroup>

       <Title>AreYouAfraidoftheDark?</Title>   

      </Item>

     </Items>

    </Data>

    最新回复(0)