GetValue
Simply returns the value property from an XmlNode whether it's null or not. Simplifies using XmlDocuments.
Source
public static string GetValue( this XmlNode node )
{
if ( node != null )
return node.Value;
else
return string.Empty;
}
Example
var xDoc = new XmlDocument();
xDoc.LoadXml(xml);
var xmlNode = xDoc.SelectSingleNode("//result/text()");
string result = xmlNode.GetValue();
// OR
string result = xDoc.SelectSingleNode("//result/text()").GetValue();