源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

jQuery读取XML文件的方法示例

  • 时间:2020-06-21 18:57 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要: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();
        ///后续操作。。。
      });
    }
  });
}

[b]PS:这里再为大家提供几款关于xml操作相关在线工具供大家参考使用:[/b] [b]在线XML/JSON互相转换工具: [/b][url=http://tools.jb51.net/code/xmljson]http://tools.jb51.net/code/xmljson[/url] [b]在线格式化XML/在线压缩XML: [/b][url=http://tools.jb51.net/code/xmlformat]http://tools.jb51.net/code/xmlformat[/url] [b]XML[/b][b]在线压缩/格式化工具: [/b][url=http://tools.jb51.net/code/xml_format_compress]http://tools.jb51.net/code/xml_format_compress[/url] [b]xml[/b][b]代码在线格式化美化工具: [/b][url=http://tools.jb51.net/code/xmlcodeformat]http://tools.jb51.net/code/xmlcodeformat[/url] 更多关于jQuery相关内容感兴趣的读者可查看本站专题:《[url=http://www.1sucai.cn/Special/354.htm]jQuery操作xml技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/294.htm]jQuery操作json数据技巧汇总[/url]》、《[url=http://www.1sucai.cn/Special/451.htm]jQuery扩展技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/200.htm]jQuery常用插件及用法总结[/url]》、《[url=http://www.1sucai.cn/Special/430.htm]jQuery常见经典特效汇总[/url]》及《[url=http://www.1sucai.cn/Special/75.htm]jquery选择器用法总结[/url]》 希望本文所述对大家jQuery程序设计有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部