linq to xml怎么读取 xml文件注释信息

.Net技术 码拜 9年前 (2015-03-30) 1175次浏览 0个评论

linq to xml怎么读取 xml文件注释信息
             var configers =
                    (from config in XDoc.Descendants(“configuration”).Descendants(“appSettings”).Descendants(“add”)
                     select new Record
                        {
                            ConfigKey = config.Attribute(“key”).Value,
                            ConfigValue = config.Attribute(“value”).Value,
                            Source = this.GetSource(s1),
                            Name = “”,
                            ConfigDesc = “”,
                            CreateDate = DateTime.Now,
                            FileName = s1,
                            Remark = “”,
                            ConfigUse = “”,
                            Version =GetVersion(s1)
                        });
怎么在读取 行记录的同时也读取上面的注释信息呢?
我想要的结果是 取到key 和value的值后,同时读取注释 然后加到 Record对象上。

 
linq to xml怎么读取 xml文件注释信息
40分
XElement e = null;
            foreach (var node in e.Nodes())
            {
                if (node.NodeType == System.Xml.XmlNodeType.Comment)
                {
                    //通过循环获取备注
                }
            }
            e.Nodes().Where(n => n.NodeType == System.Xml.XmlNodeType.Comment);//直接linq获取备注
linq to xml怎么读取 xml文件注释信息
如果你想要完全对应上,你就不能这么简单的用linq了,只能循环
linq to xml怎么读取 xml文件注释信息
https://social.microsoft.com/Forums/zh-CN/52910e98-485f-424a-b984-7e7d7a899456/c-xml?forum=visualcshartzhchs

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明linq to xml怎么读取 xml文件注释信息
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!