CgwMonitorManage.Common.CommonFunction.SetAttribute C# (CSharp) Method

SetAttribute() public static method

读取节点信息
public static SetAttribute ( XmlElement xmlElement, string nodeName, string attributeName, string attributeValue ) : void
xmlElement System.Xml.XmlElement
nodeName string
attributeName string
attributeValue string
return void
        public static void SetAttribute(XmlElement xmlElement, string nodeName, string attributeName, string attributeValue)
        {
            XmlNode node = xmlElement.SelectSingleNode(nodeName);
            if (node == null)
            {
                throw new Exception(string.Format("The node is not contain the attribute.Node:{0},attribute:{1}.", nodeName, attributeName));
            }

            XmlElement element = node as XmlElement;
            if (element == null)
            {
                throw new Exception(string.Format("The node is not contain the attribute.Node:{0},attribute:{1}.", nodeName, attributeName));
            }
            element.SetAttribute(attributeName, attributeValue);
        }