title: VB.NET check XML Node with ID exists
body: <p>I need to read a specific node from my xml but I'm getting an error (as attached) when the result doesn't exist, I'm using asp vb.net. How do I run a check to see whether the rep node with the specified id exists? Please see code below. Any help with this problem would be great</p>
  
  <p><img src="https://i.stack.imgur.com/PvMPU.jpg" alt="enter image description here"></p>
  
  <p><strong>XML</strong></p>
  
  <pre><code>&lt;repbio&gt;
    &lt;rep id="1021"&gt;
      &lt;name&gt;Tom Adams&lt;/name&gt;
      &lt;area&gt;England&lt;/area&gt;
      &lt;invested&gt;2004&lt;/invested&gt;
      &lt;since&gt;2012&lt;/since&gt;
    &lt;/rep&gt;
  &lt;/repbio&gt;
  </code></pre>
  
  <p><strong>VB.NET</strong></p>
  
  <pre><code>Dim doc As New XmlDocument()
  doc.Load(Server.MapPath("~/Files/RepBio.xml"))
  
  Dim n As XmlNode = doc.SelectSingleNode("/repbio/rep[@ID='" &amp; RepID &amp; "']")
  
  Response.Write(n("area").InnerText)
  RepAreaXml.Text = n("area").InnerText
  </code></pre>