Mega Code Archive

 
Categories / C# / XML
 

Returns the inner text of the single node selected from the specified xpath if found; otherwise, null

using System; using System.Xml; namespace SnapDragon.ECommerce.Shipping {   /// <summary>   /// Provides extensions methods for parsing xml.   /// </summary>   internal static class TrackingUtil   {     /// <summary>     /// Returns the inner text of the single node selected from the specified xpath if found; otherwise, null.     /// </summary>     /// <param name="pNode"></param>     /// <param name="pXpath"></param>     /// <returns></returns>     public static string SelectSingleNodeInnerTextOrNull(this XmlNode pNode, string pXpath)     {       XmlNode result = pNode.SelectSingleNode(pXpath);       if (result == null)       {         return null;       }       return result.InnerText;     }        } }