title: How do we check whether element with MinOccurs = 0 returned?
body: <p>I have an xml schema from a third party web service provider.</p>
  
  <pre><code>&lt;xsd:element name="Student"&gt;
  &lt;xs:sequence&gt;
      &lt;xs:element name="Name" type="xs:string" minOccurs="1"/&gt;
      &lt;xs:element name="Address" type="xs:string" minOccurs="0"/&gt;
      &lt;xs:element name="Gender" type="xs:string" minOccurs="1"/&gt;
  &lt;/xs:sequence&gt;
  &lt;/xsd:element&gt;
  </code></pre>
  
  <p>I am going to consume the dataset returns from this web service in my C# code. Since Address has the minOccurs set to 0, it means the web service can either return value for Address or not returning Address. For example:</p>
  
  <pre><code>Scenario 1:
  &lt;Student&gt;
   &lt;Name&gt;Eddie&lt;/Name&gt;
   &lt;Gender&gt;Male&lt;/Gender&gt;
  &lt;/Student&gt;
  
  Scenario 2:
  &lt;Student&gt;
   &lt;Name&gt;Alice&lt;/Name&gt;
   &lt;Address&gt;White House&lt;/Address&gt;
   &lt;Gender&gt;Female&lt;/Gender&gt;
  &lt;/Student&gt;
  
  Scenario 3:
  &lt;Student&gt;
   &lt;Name&gt;Jenny&lt;/Name&gt;
   &lt;Address&gt;&lt;/Address&gt;
   &lt;Gender&gt;Female&lt;/Gender&gt;
  &lt;/Student&gt;
  </code></pre>
  
  <p>May I know how do I check, in my C# code whether the web service return Address. </p>
  
  <p>For result set from Scenario 1, I would like to hide the contact Section from my form all together.</p>
  
  <p>For result set from Scenario 2, I would like to display the contact Section on my form, and have the address display.</p>
  
  <p>For result set from Scenario 3, I would like to display the contact Section on my form, but have the Address field in the contact section set to "Address not provided".</p>
  
  <p>May I know could I achieve that?</p>
  
  <p>I know we can check whether the elements hasvalue or isnull. But how do we check whether the result returned by the web service contains the element (Scenario 1)?</p>