读取 xml 节点的字段元素时出错 (c#)

Error reading fieldelement of xml node (c#)

在本地,SAP 将所有已安装系统的名称存储在一个 xml 文件中,位于:
%appdata%/SAP/Common/SAPUiLandscape.xml

文件看起来像这样(我不得不修改内容,因为它是机密的):

现在,我想使用以下代码 (C#) 读取所有服务节点及其子节点:

        public static System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<string, string>> GetIstalledSAPSystems()
    {
        System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<string, string>> SystemList = new System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<string, string>>();

        #region Getting folder path
        string AppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
        AppDataPath = AppDataPath.Replace('\', '/');
        if (AppDataPath.Substring(AppDataPath.Length - 1, 1) != "/") { AppDataPath += "/"; }
        AppDataPath += "SAP/Common/SAPUILandscapeMod.xml";
        #endregion

        System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
        xdoc.Load(AppDataPath);

        foreach(System.Xml.XmlNode Node in xdoc.SelectNodes("/Landscape/Services/*"))
        {
            Console.WriteLine(Node.InnerText); //Returns emptry string??
            Console.WriteLine(Node["name"].Name); //ERROR: Object reference not set to an instance of an object
            Console.WriteLine(Node["name"].Value); //ERROR: Object reference not set to an instance of an object
        }

        return SystemList;
    }

我不太明白,因为子节点 "name" 在所有元素中都可用,而且 InnerText 不应该为空。有人知道我哪里错了吗?谢谢。

节点["name"] returns 元素"name" 你应该使用Node.Attributes["name"]