做个方法递归生成上面的结构,如果要用xml就看看下面这个例子:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>创建表格(数据从xml文件中读取)</title>
<script language="javascript">
function loadXML(handler) 
{
var url = "../xml/employees.xml";
if(document.implementation && document.implementation.createDocument) 
{
var xmldoc = document.implementation.createDocument("", "", null);
xmldoc.onload =  handler(xmldoc, url);
xmldoc.load(url);
}
else if(window.ActiveXObject) 
{
var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.onreadystatechange = function() 
{
if(xmldoc.readyState == 4) handler(xmldoc, url);
}
xmldoc.load(url);
}
}
function makeTable(xmldoc, url) 
{
var table = document.createElement("table");
table.setAttribute("border","1");
table.setAttribute("cellSpacing","1");
table.setAttribute("width","600");
table.setAttribute("class","tab-content");
document.body.appendChild(table);
var caption = "Employee Data from " + url;
table.createCaption().appendChild(document.createTextNode(caption));
var header = table.createTHead();
var headerrow = header.insertRow(0);
headerrow.insertCell(0).appendChild(document.createTextNode("姓名"));
headerrow.insertCell(1).appendChild(document.createTextNode("职业"));
headerrow.insertCell(2).appendChild(document.createTextNode("工资"));
var employees = xmldoc.getElementsByTagName("employee");
for(var i=0;i<employees.length;i++) 
{
var e = employees[i];
var name = e.getAttribute("name");
var job = e.getElementsByTagName("job")[0].firstChild.data;
var salary = e.getElementsByTagName("salary")[0].firstChild.data;
var row = table.insertRow(i+1);
row.insertCell(0).appendChild(document.createTextNode(name));
row.insertCell(1).appendChild(document.createTextNode(job));
row.insertCell(2).appendChild(document.createTextNode(salary));
}
}
</script>
<link href="css/style.css" rel="stylesheet" type="text/css">
</head><body onLoad="loadXML(makeTable)">
</body>
</html>employees.xml:
<?xml version="1.0" encoding="gb2312"?>
<employees>
<employee name="J.Doe">
<job>Programmer</job>
<salary>32768</salary>
</employee>
<employee name="A.Baker">
<job>Sales</job>
<salary>70000</salary>
</employee>
<employee name="Big Cheese">
<job>CEO</job>
<salary>100000</salary>
</employee>
</employees>

解决方案 »

  1.   

    NewMenu "Configurators", "/r01/ri01.asp", '一级菜单
    NewMenu "AMD Custom Build Configurator", "/r01/ri01.asp",  '二级菜单
    NewMenuItem "Athlon 64/FX PCI-E Configurator", "/system/cfga64pcie.asp?v=d", "/images/cs/xcruiser/xcred200x160.jpg", "$CFGA64PCIE$", _ '三级及三及详细,就是四级了,
    "Socket AM2 Athlon64 3800+", _
    "nForce 500 SLI Chipset Mainboard", _
    "512MB PC6400 DDR2/800 RAM", _
    "160GB 7200RPM SATA-II HDD", _
    "nVidia 7100GS TC 256MB X16", _
    "18X DVD+-RW Drive", _
    "7.1 Onboard Sound w/ Speakers", _
    "", "", ""
    NewMenuItem "(Sckt AM2)Athlon64 FX/X2 Cfg.", "/system/cfgam2.asp?v=d", "/images/cs/sagitta/sagisil200x160.jpg", "$CFGAM2$", _
    "Socket AM2 Athlon64 X2 3800+", _
    "nForce 500 SLI Chipset Mainboard", _
    "512MB PC6400 DDR2/800 RAM", _
    "160GB 7200RPM SATA-II HDD", _
    "nVidia 7100GS TC 256MB X16 Video", _
    "18X DVD+-RW Drive", _
    "7.1 Onboard Sound w/ Speakers", _
    "", "", ""
    NewMenuItem "AMD SLI READY Custom Build Cfg.", "/system/am2_nvcfg.asp?v=d", "/images/cs/xcruiser/xcsil200x160.jpg", "$AM2_NVCFG$", _
    "Socket AM2 Athlon64 3800+", _
    "nForce 500 SLI Chipset Mainboard", _
    "512MB PC6400 DDR2/800 RAM", _
    "160GB 7200RPM SATA-II HDD", _
    "nVidia 7100GS TC 256MB X16", _
    "18X DVD+-RW Drive", _
    "7.1 Onboard Sound w/ Speakers", _
    "", "", ""
    EndMenu
    NewMenu "INTEL Custom Build Configurator", "/r01/ri01.asp", mnuLeft + menuwidth - 1, mnuTop + 1 * 20
    NewMenuItem "Core 2 Duo Configurator", "/system/cfgc2d.asp?v=d", "/images/cs/xdiscovery/xdcysil200x160.jpg", "$CFGC2D$", _
    "Intel Core 2 Duo E6300 CPU", _
    "P965 SLI Chipset Mainboard", _
    "512MB PC6400 DDR2/800 RAM", _
    "160GB 7200RPM SATA-II HDD", _
    "nVidia 7300LE 256MB X16 Video", _
    "18X DVD+-R/RW Drive", _
    "7.1 Onboard Sound w/ Speakers", _
    "", "", ""
    NewMenuItem "Pentium 4 PCI-E Configurator", "/system/cfgintelpcie.asp?v=d", "/images/cs/stacker/stacker200x160.jpg", "$CFGINTELPCIE$", _
    "Intel Pentium D 805 2.66GHz CPU", _
    "nForce 570 SLI Chipset Mainboard", _
    "512MB PC5300 DDR2/667 RAM", _
    "160GB 7200RPM SATA-II HDD", _
    "nVidia 6200TC 256MB X16 Video", _
    "18X DVD+-R/RW Drive", _
    "5.1 Onboard Sound w/ Speakers", _
    "", "", ""
    NewMenuItem "Pentium Dual-Core Configurator", "/system/cfgpd.asp?v=d", "/images/cs/zero/01_200x160.jpg", "$CFGPD$", _
    "Intel Pentium D 945 3.4GHz CPU", _
    "nForce 570 SLI Chipset Mainboard", _
    "512MB PC5300 DDR2/667 RAM", _
    "160GB 7200RPM SATA-II HDD", _
    "nVidia 7100GS TC 256MB X16 Video", _
    "18X DVD+-R/RW Drive", _
    "7.1 Onboard Sound w/ Speakers", _
    "", "", ""
    EndMenu
    EndMenu
    有六个这样的循环
      

  2.   

    这个循环出来的是啥东西(ASP我不太熟悉)?你这个菜单项都是写死在代码中的?
      

  3.   

    要不,我把这些菜单项目直接写在xml里也可以是吧?
      

  4.   

    可以,然后读取xml,循环遍历。
      

  5.   

    dom操作可以参考http://blog.csdn.net/adverse/archive/2007/04/16/1566148.aspx