Mega Code Archive

 
Categories / C# / XML
 

Returns the InnerText value from a node or string Empty if the node is null

using System; using System.Xml; namespace Microsoft.SnippetLibrary {     /// <summary>     /// Summary description for Util.     /// </summary>     public class Utility     {         /// <summary>         /// Returns the InnerText value from a node          /// or string.Empty if the node is null.         /// </summary>         /// <param name="element"></param>         /// <returns></returns>         public static string GetTextFromElement(XmlElement element)         {             if (element == null)                 return string.Empty;             else                 return element.InnerText;         }     } }