title: Is there a faster way to check for an XML Element in LINQ to XML?
body: <p>Currently I'm using the following extension method that I made to retrieve the values of elements using LINQ to XML.  It uses <code>Any()</code> to see if there are any elements with the given name, and if there are, it just gets the value.  Otherwise, it returns an empty string.  The main use for this method is for when I'm parsing XML into C# objects, so I don't want anything blowing up when an element is not there.</p>
  
  <p>I have other extension methods for the other data type like bool, int and double, and some custom ones for parsing custom strings into enums or bools.  I also have those same methods for working with attributes.</p>
  
  <p>Is there a better way to do this?</p>
  
  <pre><code>/// &lt;summary&gt;
  /// If the parent element contains a element of the specified name, it returns the value of that element.
  /// &lt;/summary&gt;
  /// &lt;param name="x"&gt;The parent element.&lt;/param&gt;
  /// &lt;param name="elementName"&gt;The name of the child element to check for.&lt;/param&gt;
  /// &lt;returns&gt;The value of the child element if it exists, or an empty string if it doesn't.&lt;/returns&gt;
  public static string GetStringFromChildElement(this XElement x, string elementName)
  {
      return x.Elements(elementName).Any() ? x.Element(elementName).Value : string.Empty;
  }
  </code></pre>