html文件:shop.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns=""> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script language="javascript"> function movenext(){ if(product.recordset.absoluteposition<product.recordset.recordcount) { product.recordset.movenext(); } } function moveprevious(){ if(product.recordset.absoluteposition>1) { product.recordset.moveprevious(); } } function xmlfirst(){ product.recordset.movefirst(); } function xmllast(){ product.recordset.movelast(); } </script> </head><body>
<xml ID="product" src="js_xml.xml"> </xml><table> <tr><td>商品编号:<span datasrc=#product datafld="id"></span></td></tr> <tr><td>商品名称:<span datasrc=#product datafld="name"></span></td></tr> <tr><td>商品类别:<span datasrc=#product datafld="leibie"></span></td></tr> <tr><td>商品价格:<span datasrc=#product datafld="price"></span></td></tr> </table> <input type="button" value="第一条记录" /> <input type="button" value="上一个" /> <input type="button" value="下一个" /> <input type="button" value="最后一条记录" /> </body> </html>
xml文件:js_xml.xml
<?xml version="1.0" encoding="utf-8"?>
<shop> <product> <id>00001</id> <name>铅笔</name> <leibie>文具</leibie> <price>11</price> </product> <product> <id>00002</id> <name>裙子</name> <leibie>服装</leibie> <price>77</price> </product> <product> <id>00003</id> <name>裤子</name> <leibie>服装</leibie> <price>55</price> </product> <product> <id>00004</id> <name>牙膏</name> <leibie>生活用品</leibie> <price>6.5</price> </product> <product> <id>00005</id> <name>牙刷</name> <leibie>生活用品</leibie> <price>2.5</price> </product> </shop>结果为: