Beispiel #1
0
        /// <summary>
        /// 获取XML文件根节点
        /// </summary>
        /// <param name="filePath">文件名称</param>
        /// <param name="isRequest">是否是客户端请求</param>
        /// <returns></returns>
        public XElement GetRootElement(string filePath, bool isRequest = true)
        {
            var physicalPath = FilePathTools.GetFilePhysicalPath(filePath, isRequest);

            if (!File.Exists(physicalPath))
            {
                throw new Exception("文件不存在");
            }
            XDocument xDoc = XDocument.Load(physicalPath);

            return(xDoc.Root);
        }