title: How to read a XML self-closing tag in Excel VBA?
body: <p>I have a XML file that contains a tag that can either have text or can be self-closing when it has no text.</p>
  
  <p>Case 1 (with text):</p>
  
  <pre><code>&lt;Example&gt;
     &lt;size&gt;512&lt;/size&gt;
  &lt;/Example&gt;
  </code></pre>
  
  <p>Case 2 (no text - self-closing):</p>
  
  <pre><code>&lt;Example&gt;
     &lt;size /&gt;
  &lt;/Example&gt;
  </code></pre>
  
  <p>I want to read this tag text in Excel VBA.
  In Case 1, no problem, I do the following:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Set oXMLFile = CreateObject("Microsoft.XMLDOM")
  oXMLFile.Load ("File.xml")
  size = oXMLFile.SelectSingleNode("/Example/size/text()").NodeValue
  </code></pre>
  
  <p>But in Case 2, the <code>SelectSingleNode</code> function returns this error:</p>
  
  <blockquote>
    <p>Run-time error '438':<br>
    Object doesn't support this property or method</p>
  </blockquote>
  
  <p>How can I handle Case 2 so that it returns me an empty string? Is there a built-in VBA function to test if a tag is self-closing?</p>