public static string GetChildNodeInnerText(XmlNode node, string childNodeName, ReturnCanBeEmpty fieldRequired) { #region Argument Check if (node == null) { throw new ArgumentException(string.Format("Parent null node passed trying to get '{0}' child node inner test", childNodeName)); } if (node[childNodeName] == null) { throw new ArgumentException(string.Format("null child node passed trying to get '{0}' child node inner test", childNodeName)); } #endregion string retValue = string.Empty; if (!string.IsNullOrEmpty(node[childNodeName].InnerText)) { retValue = node[childNodeName].InnerText; } else if (fieldRequired == ReturnCanBeEmpty.No) { string errMsg = string.Format("GetChildNodeInnerText would have returned an empty string, but this is not allowed as ReturnCanBeBlank argument is set to No. node:'{0}' childNodeName:'{1}'", node.Name, childNodeName); throw new ArgumentException(errMsg); } return retValue; }
public static string GetChildNodeInnerText(XmlNode node, string childNodeName, ReturnCanBeEmpty fieldRequired) { #region Argument Check if (node == null) { throw new ArgumentException(string.Format("Parent null node passed trying to get '{0}' child node inner test", childNodeName)); } if (node[childNodeName] == null) { throw new ArgumentException(string.Format("null child node passed trying to get '{0}' child node inner test", childNodeName)); } #endregion string retValue = string.Empty; if (!string.IsNullOrEmpty(node[childNodeName].InnerText)) { retValue = node[childNodeName].InnerText; } else if (fieldRequired == ReturnCanBeEmpty.No) { string errMsg = string.Format("GetChildNodeInnerText would have returned an empty string, but this is not allowed as ReturnCanBeBlank argument is set to No. node:'{0}' childNodeName:'{1}'", node.Name, childNodeName); throw new ArgumentException(errMsg); } return(retValue); }