本帖最后由 u014688838 于 2014-04-14 22:06:40 编辑

解决方案 »

  1.   

    获取根元素直接用:doc.DocumentElement
    比如Console.WriteLine(doc.DocumentElement.Name); //输出root
      

  2.   

    SelectNodes   里面的参数用错了
      

  3.   

    根节点用doc.DocumentElement就可以了。
      

  4.   

    System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.Load(fileName);
                System.Xml.XmlElement root = (System.Xml.XmlElement)doc.SelectSingleNode("config");
      

  5.   

    使用linq to xml 吧
     XElement xmlDoc =  XElement.Load(路径);
    IEnumerable<XElement> = xmlDoc.Elements("root");