ext解析XML

  1. Ext.onReady(function(){  
  2.                 //alert();  
  3.                 var store = new Ext.data.Store({  
  4.                     url: 'hello.xml',  
  5.                     reader: new Ext.data.XmlReader({  
  6.                         record: 'country'  
  7.                     }, [{  
  8.                         name: 'country',  
  9.                         mapping: 'cid'  
  10.                     }])  
  11.                 });  
  12.                 store.load()  
  13.                 alert(store.getCount());  
  14.             });  


xml 文件 

<?xml version="1.0" encoding="utf-8"?> 
<conf> 
    <country name="China"> 
        <cid>China</cid> 
            <province name="ShanXi"> 
                <pid>ShanXi</pid> 
                <city>TaiYuan</city> 
                <city>DaTong</city> 
                <city>YunCheng</city> 
            </province> 
    </country> 
    <country name="America"> 
        <cid>America</cid> 
            <province name="Florida"> 
                <pid>aaa</pid> 
                <city>bbb</city> 
                <city>ccc</city> 
                <city>ddd</city> 
            </province> 
    </country> 
</conf> 

你可能感兴趣的:(ext解析XML)