1.xml ドキュメントのコンテンツ:
<?xml version="1.0" encoding="utf-8" ?><bookstore> <book category="children"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="cooking"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="web"> <title lang="en">Learning XML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> <book category="web"> <title lang="en">XQuery Kick Start</title> <author>James McGovern</author> <author>Per Bothner</author> <author>Kurt Cagle</author> <author>James Linn</author> <author>Vaidyanathan Nagarajan</author> <year>2003</year> <price>49.99</price> </book></bookstore>
function loadXMLDoc(dname) {try //Internet Explorer { xmlDoc=new ActiveXObject("Microsoft.XMLDOM");//创建空的微软xml文档对象 }catch(e) { try //Firefox, Mozilla, Opera, etc. { xmlDoc=document.implementation.createDocument("","",null);//其他浏览器通过解析器创建xml文档对象 } catch(e) {alert(e.message)} }try { xmlDoc.async=false;//关闭异步加载,确保文档加载完之前解析器不会继续执行脚本 xmlDoc.load(dname);//加载文档 return(xmlDoc);//返回xml文档对象 }catch(e) {alert(e.message)}return(null);}
3. XML ドキュメントの下のすべてのノードを走査します
れーれー