案例:XML DOM案例     状态:可编辑再运行    进入横版
x
 
1
<html>
2
<body>
3
<script type="text/javascript">
4
text="<bookstore>"
5
text=text+"<book>";
6
text=text+"<title>Harry Potter</title>";
7
text=text+"<author>J K. Rowling</author>";
8
text=text+"<year>2005</year>";
9
text=text+"</book>";
10
text=text+"</bookstore>";
11
12
try //Internet Explorer
13
  {
14
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
15
  xmlDoc.async="false";
16
  xmlDoc.loadXML(text);
17
  }
18
catch(e)
19
  {
20
  try //Firefox, Mozilla, Opera, etc.
21
    {
22
    parser=new DOMParser();
23
    xmlDoc=parser.parseFromString(text,"text/xml");
24
    }

 运行结果 
 北美留学生论坛