jQuery 解析xml文件
来源:互联网 发布:linux设定文件夹权限 编辑:程序博客网 时间:2024/06/17 19:51
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>jquery xml解析</title> <script src="jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $.ajax({url:"City.xml", success:function(xml){ $(xml).find("province").each(function(){ var t = $(this).attr("name");//this-> $("#DropProvince").append("<option>"+t+"</option>"); }); } }); $("#DropProvince").change(function(){ $("#sCity>option").remove(); var pname = $("#DropProvince").val(); $.ajax({url:"City.xml", success:function(xml){ $(xml).find("province[name='"+pname+"']>city").each(function(){ $("#sCity").append("<option>"+$(this).text()+"</option>"); }); } }); }); }); </script> </head> <body> <form id="form1"> <div> <select id="DropProvince" style="width:60px;"> <option>请选择</option> </select> <select id="sCity" style="width:60px;"> </select> </div> </form> </body> </html>
city.xml文件
<?xml version="1.0" encoding="utf-8" ?> <provinces> <province name="湖北"> <city>武汉</city> <city>黄石</city> <city>宜昌</city> <city>天门</city> </province> <province name="湖南"> <city>邵阳</city> <city>长沙</city> <city>岳阳</city> </province> <province name="广东"> <city>广州</city> <city>深圳</city> </province> </provinces>
其实主要是注意怎样在html界面上解析xml文件,格式就是
<script type="text/javascript"> $(document).ready(function () { $.ajax({ url: "City.xml", success: function (xml) { $(xml).find("province").each(function () { var t = $(this).attr("name"); $("#DropProvince").append("<option>" + t + "</option>"); }); } }); $("#DropProvince").change(function () { $("#sCity>option").remove(); var pname = $("#DropProvince").val(); $.ajax({ url: "City.xml", success: function (xml) { $(xml).find("province[name='"+pname+"']>city").each(function(){ $("#sCity").append("<option>"+$(this).text()+"</option>"); }); } }); }); }); </script>
就是用
0 0
- jQuery 解析xml文件
- jQuery 解析xml文件
- jQuery 解析xml文件
- JQuery解析xml文件
- jquery解析XML文件
- jQuery 解析xml文件
- jquery解析xml文件
- JQuery -- Jquery 中的Ajax, Jquery解析xml文件
- jquery解析XML字符串或XML文件的方法
- jquery解析XML字符串或XML文件的方法
- jQuery学习之八-----jQuery解析xml文件(摘录)
- jQuery解析XML文件同时动态增加js文件
- Jquery读取json文件和xml文件以及解析
- jQuery行级解析读取XML文件(附源码)
- ie中jQuery无法解析xml文件的解决方案
- ie中jQuery无法解析xml文件的解决方案
- 用jQuery解析复杂的xml结构文件
- jquery 解析带命名空间的xml文件
- Javaweb项目中使用Log4j记录日志
- (2016年中国大学生程序设计竞赛(杭州) )HDU 5943 Kingdom of Obsession 素数间距 + 匈牙利算法
- 设置Log4j 日志文件存放位置
- MATLAB的符号计算
- MATLAB 积分求解
- jQuery 解析xml文件
- JVM性能调优
- 手算以及使用线性神经网络和感知器…
- [BZOJ4596][Shoi2016]黑暗前的幻想乡-Matrix Tree 矩阵树定理
- 线性神经网络用于求解异或逻辑
- BP神经网络的结构
- BP网络的学习算法
- 设计BP神经网络
- BP网络相关matlab函数:Sigmoid函…