案例:XML案例     状态:可编辑再运行    进入横版
x
txt="Artist: "+artist+"<br />Title: "+title+"<br />Year: "+year+"<br />Country: "+country+"<br />Company: "+company+"<br />Price: "+price  ;
 
1
<html>
2
<head>
3
<script type="text/javascript">
4
if (window.XMLHttpRequest)
5
  {// code for IE7+, Firefox, Chrome, Opera, Safari
6
  xmlhttp=new XMLHttpRequest();
7
  }
8
else
9
  {// code for IE6, IE5
10
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
11
  }
12
xmlhttp.open("GET","/example/xmle/cd_catalog.xml",false);
13
xmlhttp.send();
14
xmlDoc=xmlhttp.responseXML; 
15
x=xmlDoc.getElementsByTagName("CD");
16
17
function displayCDInfo(i)
18
{
19
artist=(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue);
20
title=(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);
21
year=(x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue);
22
country=(x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue);
23
company=(x[i].getElementsByTagName("COMPANY")[0].childNodes[0].nodeValue);
24
price=(x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue);

 运行结果 
 北美留学生论坛