<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script type="text/javascript" language="javascript">
var xmlObj = new ActiveXObject("Msxml2.DOMDocument");
xmlObj.load("E:\\Documents and Settings\\jasonhuang\\Desktop\\xmlA.xml");
var obj = xmlObj.selectNodes("breakfast_menu/food");

window.onload = function()
{
if (obj.length == 0) return;

var table = document.createElement("<table border='1px' cellpadding='0' cellspacing='0'></table>");
for (var nI=0; nI < obj.length; nI++)
{
var tr = document.createElement("tr");

for (var nJ=0; nJ<obj.item(nI).childNodes.length; nJ++)
{
var itm = obj.item(nI).childNodes.item(nJ);
var td = document.createElement("td");

td.innerHTML = itm.text;
tr.appendChild(td);
}
table.appendChild(tr);
}
document.body.appendChild(table);
}
</script>
</head><body>

</body>
</html>
XML文件:
<?xml version="1.0" encoding="ISO-8859-1" ?> 
<breakfast_menu>
  <food>
  <name>Belgian Waffles</name> 
  <price>$5.95</price> 
  <description>two of our famous Belgian Waffles with plenty of real maple syrup</description> 
  <calories>650</calories> 
</food>
<food>
  <name>Strawberry Belgian Waffles</name> 
  <price>$7.95</price> 
  <description>light Belgian waffles covered with strawberries and whipped cream</description> 
  <calories>900</calories> 
</food>
<food>
  <name>Berry-Berry Belgian Waffles</name> 
  <price>$8.95</price> 
  <description>light Belgian waffles covered with an assortment of fresh berries and whipped cream</description> 
  <calories>900</calories> 
</food>
<food>
  <name>French Toast</name> 
  <price>$4.50</price> 
  <description>thick slices made from our homemade sourdough bread</description> 
  <calories>600</calories> 
</food>
<food>
  <name>Homestyle Breakfast</name> 
  <price>$6.95</price> 
  <description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description> 
  <calories>950</calories> 
</food>
</breakfast_menu>