Example of jQuery's method for reading XML files, and jquery's method for reading xml files

Source: Internet
Author: User

Example of jQuery's method for reading XML files, and jquery's method for reading xml files

This document describes how jQuery reads XML files. We will share this with you for your reference. The details are as follows:

<?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 (" An error occurred while loading the xml file! ") ;}, 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 (); // subsequent operations... });}});}

PS: Here are some online tools related to xml operations for your reference:

Online XML/JSON conversion tools:
Http://tools.jb51.net/code/xmljson

Online formatting XML/online compression XML:
Http://tools.jb51.net/code/xmlformat

XMLOnline compression/formatting tools:
Http://tools.jb51.net/code/xml_format_compress

XmlCode Online formatting and beautification tools:
Http://tools.jb51.net/code/xmlcodeformat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.