大家帮忙看看下面那里有错误啊var xmlDom = new ActiveXObject("Msxml2.DOMDocument");
xmlDom.async = false;
xmlDom.loadXML("d:\\db\\type.xml")
//var items = xmlDom.selectNodes("/NewDataSet/table_dimension");

for (i=0;i<xmlDom.childNodes.length;i++)
{
if (xmlDom.childNodes(i).getAttribute("direction")=="a")
{
x=xmlDom.childNodes(i).getAttribute("dimension");
}else if(xmlDom.childNodes(i).getAttribute("direction")=="b")
{
y=xmlDom.childNodes(i).getAttribute("dimension");
}else if(xmlDom.childNodes(i).getAttribute("direction")=="d")
{
z=xmlDom.childNodes(i).getAttribute("dimension");
}
}<NewDataSet>
  <table_dimension>
    <cube_id>2</cube_id>
    <direction>a</direction>
    <dimension>投注方式</dimension>
  </table_dimension>
  <table_dimension>
    <cube_id>2</cube_id>
    <direction>b</direction>
    <dimension>玩法类型</dimension>
  </table_dimension>
  <table_dimension>
    <cube_id>2</cube_id>
    <direction>d</direction>
    <dimension>金额</dimension>
  </table_dimension>
</NewDataSet>

解决方案 »

  1.   

    var xmlDom = new ActiveXObject("Msxml2.DOMDocument");
    xmlDom.async = false;
    xmlDom.loadXML("d:\\db\\type.xml")
    var items1 = xmlDom.selectNodes("//NewDataSet/cube_id"); 
    var items2 = xmlDom.selectNodes("//NewDataSet/table_dimension"); 
    var items3 = xmlDom.selectNodes("//NewDataSet/dimension"); 
    var itemsLength=items1.length;
    for (i=0;i<itemsLength;i++)
    {
    if (items2[i].text=="a")
    {
    x=items2[i].text;
    }else ...
    }
      

  2.   

    var name = items.childNodes[i].attributes["Name"].value;