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);
}