AutoCAD 3DMAX C语言 Pro/E UG JAVA编程 PHP编程 Maya动画 Matlab应用 Android
Photoshop Word Excel flash VB编程 VC编程 Coreldraw SolidWorks A Designer Unity3D
 首页 > JavaScript

jQuery读取XML文件的方法示例

51自学网 http://www.wanshiok.com
jQuery,读取,XML文件

本文实例讲述了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 文件出错!");    },    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();        ///后续操作。。。      });    }  });}

PS:这里再为大家提供几款关于xml操作相关在线工具供大家参考使用:

在线XML/JSON互相转换工具:
http://tools.wanshiok.com/code/xmljson

在线格式化XML/在线压缩XML
http://tools.wanshiok.com/code/xmlformat

XML在线压缩/格式化工具:
http://tools.wanshiok.com/code/xml_format_compress

xml代码在线格式化美化工具:
http://tools.wanshiok.com/code/xmlcodeformat

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery操作xml技巧总结》、《jQuery操作json数据技巧汇总》、《jQuery扩展技巧总结》、《jQuery常用插件及用法总结》、《jQuery常见经典特效汇总》及《jquery选择器用法总结

希望本文所述对大家jQuery程序设计有所帮助。


jQuery,读取,XML文件  
上一篇:折叠菜单及选择器的运用  下一篇:JavaScript函数基础详解