jQuery讀取XML文件的方法示例
本文實(shí)例講述了jQuery讀取XML文件的方法。分享給大家供大家參考,具體如下:
<?xml version="1.0" encoding="utf-8" ?> <taxrates> <taxrate id="1"> <lower>0</lower> <upper>500</upper> <rate>5</rate> <buckle>0</buckle> </taxrate> <taxrate id="2"> <lower>500</lower> <upper>2000</upper> <rate>10</rate> <buckle>25</buckle> </taxrate> <taxrate id="3"> <lower>2000</lower> <upper>5000</upper> <rate>15</rate> <buckle>125</buckle> </taxrate> <taxrate id="4"> <lower>5000</lower> <upper>20000</upper> <rate>20</rate> <buckle>375</buckle> </taxrate> <taxrate id="5"> <lower>20000</lower> <upper>40000</upper> <rate>25</rate> <buckle>1375</buckle> </taxrate> <taxrate id="6"> <lower>40000</lower> <upper>60000</upper> <rate>30</rate> <buckle>3375</buckle> </taxrate> <taxrate id="7"> <lower>60000</lower> <upper>80000</upper> <rate>35</rate> <buckle>6375</buckle> </taxrate> <taxrate id="8"> <lower>80000</lower> <upper>100000</upper> <rate>40</rate> <buckle>10375</buckle> </taxrate> <taxrate id="9"> <lower>100000</lower> <upper>99999999</upper> <rate>45</rate> <buckle>15375</buckle> </taxrate> </taxrates>
function StandardTaxRate() { $.ajax({ url: "/Resource/salaryTaxRate.xml", dataType: 'xml', type: 'GET', timeout: 2000, error: function(xml) { alert("加載XML 文件出錯(cuò)!"); }, success: function(xml) { $(xml).find("taxrate").each(function(i) { var oid = $(this).attr("id"); var lower = $(this).children("lower").text(); var upper = $(this).children("upper").text(); var rate = $(this).children("rate").text(); var buckle = $(this).children("buckle").text(); ///后續(xù)操作。。。 }); } }); }
PS:這里再為大家提供幾款關(guān)于xml操作相關(guān)在線工具供大家參考使用:
在線XML/JSON互相轉(zhuǎn)換工具:
http://tools.jb51.net/code/xmljson
在線格式化XML/在線壓縮XML:
http://tools.jb51.net/code/xmlformat
XML在線壓縮/格式化工具:
http://tools.jb51.net/code/xml_format_compress
xml代碼在線格式化美化工具:
http://tools.jb51.net/code/xmlcodeformat
更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery操作xml技巧總結(jié)》、《jQuery操作json數(shù)據(jù)技巧匯總》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery常見經(jīng)典特效匯總》及《jquery選擇器用法總結(jié)》
希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。
- jQuery加載及解析XML文件的方法實(shí)例分析
- jQuery+ajax讀取并解析XML文件的方法
- jQuery處理XML文件的幾種方法
- jQuery實(shí)現(xiàn)定時(shí)讀取分析xml文件的方法
- jQuery解析XML文件同時(shí)動(dòng)態(tài)增加js文件的方法
- jquery讀取xml文件實(shí)現(xiàn)省市縣三級(jí)聯(lián)動(dòng)的方法
- jQuery讀取XML文件內(nèi)容的方法
- jquery解析XML字符串和XML文件的方法說明
- JQuery讀取XML文件數(shù)據(jù)并顯示的實(shí)現(xiàn)代碼
- jQuery 行級(jí)解析讀取XML文件(附源碼)
- jQuery 解析xml文件
相關(guān)文章
jQuery實(shí)現(xiàn)當(dāng)按下回車鍵時(shí)綁定點(diǎn)擊事件
當(dāng)按下回車鍵時(shí),綁定按鈕點(diǎn)擊事件,本文為大家介紹下jQuery回車鍵綁定點(diǎn)擊事件的具體實(shí)現(xiàn)2014-01-01jQuery 利用$.ajax 時(shí)獲取原生XMLHttpRequest 對(duì)象的方法
這篇文章主要介紹了jQuery 利用$.ajax 時(shí)獲取原生XMLHttpRequest 對(duì)象的方法,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-08-08解決checkbox的attr(checked)一直為undefined問題
需要做個(gè)一個(gè)全選的checkbox功能,遇到checkbox的attr("checked")一直為undefined,下面與大家分享下最終的解決方案2014-06-06jquery.AutoComplete.js中文修正版(支持firefox)
jquery.AutoComplete.js中文修正版(支持firefox),注意是修正了輸入中文的一些bug,需要的朋友可以測(cè)試下。2010-04-04jQuery EasyUI ProgressBar進(jìn)度條組件
這篇文章主要為大家詳細(xì)介紹了jQuery EasyUI ProgressBar進(jìn)度條組件的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02jQuery 學(xué)習(xí)入門篇附實(shí)例代碼
這篇文章比較不錯(cuò),更重要的是一些實(shí)例代碼,對(duì)于想學(xué)習(xí)jquery的朋友是個(gè)不錯(cuò)的資料。2010-03-03jQuery ztree實(shí)現(xiàn)動(dòng)態(tài)樹形多選菜單
這篇文章主要介紹了jQuery ztree實(shí)現(xiàn)動(dòng)態(tài)樹形多選菜單,ztree動(dòng)態(tài)樹形菜單,初始化加載和延遲加載,感興趣的小伙伴們可以參考一下2016-08-08