帮你顶。
改为:Console.wireteline(node.GetAttribute["Genre"]),可能还要转化为String。["Genre"]若改为索引可为:GetAttribute(i);

解决方案 »

  1.   

    XmlNode没有GetAttribute方法啊,而且我想知道我错在哪里
      

  2.   


    那就是实际上这个node 对象根本还没有建立起来
    你是在构造函数中调用了这个方法
      

  3.   


    public void Find(XmlNode node)
    {        
                      XmlAttributeCollection xxx= node.Attributes
    if(xxx!= null)
        Console.WriteLine (xxx.item[i]);循环求出
    }
      

  4.   

    public void Find(XmlNode node)
    {   
      if(node.NodeType == XmlNodeType.Element && 
         node.Attributes["genre"] != null)
         Console.WriteLine (node.Attributes["genre"].Value );
    }
      

  5.   

    并不是所有类型的 XmlNode 都能返回 Attributes 属性的。
    因为你递归调用了 Display 方法,而 “Pride And Prejudice” 是 Text 类型的节点,作为名为“title ”的 Element 节点的一个子节点,恰好它是不具备有意义的 Attributes 属性的。程序的错误是因为你没有理解 Text 节点类型, 可能你认为 title 节点下是没有子节点的。而事实上恰恰相反。一般来说,Text 节点下是不会有子节点了。