title: How to check if XML value exist?
body: <p>I'm trying to get data from XML. What I know is that I always get an error when the animal i'm trying to find is not in the XML data. An example as shown.</p>
  
  <p>This is the data stored in XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;Root&gt;
  &lt;Animal value="Elephant" size="2" name="Bob"&gt;
      &lt;Action age="1" size="1"&gt;I am small&lt;/Action&gt;
      &lt;Action age="2" size="1"&gt;I am growing up&lt;/Action&gt;
      &lt;Action age="3" size="1"&gt;I'm 3 years old&lt;/Action&gt;
      &lt;Action age="4" size="1"&gt;I'm BIG&lt;/Action&gt;
  &lt;/Animal&gt;
  &lt;/Root&gt;
  </code></pre>
  
  <p>This is part of the C# coding:</p>
  
  <pre><code>XmlDocument xDoc = new XmlDocument();
  xDoc.Load("animals.xml");
  string animal = "Elephant";
  MessageBox.Show(Convert.ToString(xDoc.SelectSingleNode("/Root/Animal[@value='" + animal + "']")
                                       .Attributes["name"].InnerText));
  </code></pre>
  
  <p>The error occurs when I change</p>
  
  <pre><code>string animal = "Tiger";
  </code></pre>
  
  <p>How do I solve the error if the data does not exist?</p>