public static string GetAttribute(XmlElement xmlElement, string nodeName, string attributeName)
{
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));
}
string attributeValue = element.GetAttribute(attributeName).Trim();
if (string.IsNullOrEmpty(attributeValue))
{
throw new Exception(string.Format("The node is not contain the attribute.Node:{0},attribute:{1}.", nodeName, attributeName));
}
return attributeValue;
}