码迷,mamicode.com
首页 > Web开发 > 详细

jquery加载解析XML文件

时间:2015-05-30 21:11:39      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

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>
</taxrates>

jquery代码

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();
                ///后续操作。。。
            });
        }
    });
}

 

jquery加载解析XML文件

标签:

原文地址:http://www.cnblogs.com/yushuo/p/4540964.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!