Painter/Component/XmlManage.cs

(开头部分) 7KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Xml;

namespace Painter.Component
{
    public static class XmlManage
    {
        static object LOCK = new object();
        /// <summary>
        /// 获取指定xml文件中的键值
        /// </summary>
        /// <param name="nodeName"></param>
        ///<param name="key"></param> 
        /// <param name="xmlPath"></param>
        /// <returns></returns>
        public static string GetKeyValue(string nodeName, string key, string xmlPath)
        {

            XmlNodeList xNode = GetXmlNodes(nodeName, xmlPath);
            if (xNode.Count > 0)
            {
                return xNode[0].Attributes[key].Value;
            }
            return "";
        }

        /// <summary>
        /// 获取指定xml文件中的键值
        /// </summary>
        /// <param name="nodeName"></param>
        ///<param name="key"></param> 
        /// <param name="xmlPath"></param>
        /// <returns></returns>
        public static string GetKeyValue(string nodeName, string xmlStr)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xmlStr);
            XmlNode xNode = xmlDoc.SelectSingleNode(nodeName);
            return xNode.Value;
        }

        /// <summary>
        /// 加载xml节点内容
        /// </summary>
        /// <param name="nodeName"></param>
        /// <param name="xmlPath"></param>
        /// <returns></returns>
        public static XmlNodeList GetXmlNodes(string nodeName, string xmlPath)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(AppDomain.CurrentDomain.BaseDirectory + xmlPath);
            return xmlDoc.SelectNodes("//" + nodeName);
        }


        #region SetConfiguration
后面还有 134 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。