JS加载xml文档实例
books.xml
www.jb51.net
J K. Rowling
2005
29.99
Everyday Italian
Giada De Laurentiis
2005
30.00
Learning XML
Erik T. Ray
2003
39.95
XQuery Kick Start
James McGovern
Per Bothner
Kurt Cagle
James Linn
Vaidyanathan Nagarajan
2003
49.99
loadxml.htm
<script> <BR>try //Internet Explorer <BR>{ <BR>xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); <BR>} <BR>catch(e) <BR>{ <BR>try //Firefox, Mozilla, Opera, etc. <BR>{ <BR>xmlDoc=document.implementation.createDocument("","",null); <BR>} <BR>catch(e) {alert(e.message)} <BR>} <BR>try <BR>{ <BR>xmlDoc.async=false; <BR>xmlDoc.load("books.xml"); <BR>document.write(xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue); } <BR>catch(e){alert(e.message);} <BR></script>
下面的是加载与解析xml文件的例子,但xml是自定义的字符串,一般在后台语言中用的到。