XML在Web中的简单应用
来源:互联网 发布:linux用man查看ls 编辑:程序博客网 时间:2024/05/13 23:24
首先建立一个Area.html,很简单包含一个省份的select元素和一个城市的界面元素:
<html>
<head>
<title>Area Demo</title>
</head>
<body>
<select id="province" size=1 onchange="loadCity()">
<option value="city01.xml"> 江苏 </option>
<option value="city02.xml"> º湖南 </option>
<option value="city03.xml"> 湖北 </option>
</select>
<select id="city" size=1>
</select>
<xml id="xmlobj"></xml>
<script language="javascript" type="text/javascript">
var provobj = document.all("province");
var cityobj = document.all("city");
var xmlhttp = document.all("xmlobj");
loadCity();
/**
* 装载城市数据
*/
function loadCity() {
cityobj.options.length = 0;
var file = provobj.options[provobj.selectedIndex].value;
xmlhttp.async = false;
xmlhttp.load(file);
var cities = xmlhttp.selectNodes("Cities/City");
var idx,name;
for(idx = 0; idx < cities.length; idx ++) {
name = cities[idx].getAttribute("name");
cityobj.options.length++;
cityobj.options[cityobj.options.length - 1].value = name;
cityobj.options[cityobj.options.length - 1].text = name;
}
}
</script>
</body>
</html>
然后建立三个省份的城市数据文件,分别命名为city01.xml,city02.xml,city03.xml
<?xml version="1.0" encoding="GB2312"?>
<Cities Province="江苏">
<City name="南京"/>
</Cities>
<?xml version="1.0" encoding="GB2312"?>
<Cities Province="湖南">
<City name="长沙"/>
</Cities>
<?xml version="1.0" encoding="GB2312"?>
<Cities Province="湖北">
<City name="武汉"/>
</Cities>
保存,在ie6浏览通过,理论上可以在ie5一上浏览器跑。
- XML在Web中的简单应用
- XML在Web中的简单应用
- XML在Web中的简单应用
- XML在Web中的简单应用
- XML在WEB开发中的应用
- 数据字典在web中的简单应用
- 基于XML的Web数据挖掘在数字图书馆中的应用
- J2EE 应用 proxool连接池,在web.xml中的配置
- xml在Web中的作用
- xml在数据库中的应用
- XPath在xml中的应用
- XML在DELPHI中的应用
- XML在参数中的应用
- ZedGraph在web中的应用
- QuartZ在Web中的应用
- QuartZ在Web中的应用
- hibernate2在web中的应用
- jdbc在web中的应用
- 在关系数据库中保存大量XML文档
- 面向机器翻译的全文检索系统
- 利用XSLT把ADO记录集转换成XML
- 生活在01两中状态中
- XP sp2对socket函数的影响
- XML在Web中的简单应用
- EJB学习之入门初探篇-EJB技术的发展史
- 把你的GUI写成XML文件
- 一个孤独的流浪汉
- 林俊杰 -《编号89757》
- 有一种遗憾让我们泪流满面
- 防止垃圾邮件用你的邮件服务器转发
- 请问FOXPRO 的DBF表怎么直接导入到SQL里面去啊
- POSIX操作系统串口编程(1)