title: XPath: Default to 'Node A', select 'Node B' instead if 'Node B' is not empty
body: <p>I need to create an XPath expression that does the following:</p>
  
  <ul>
  <li>Returns the element inside of 'NodeA' by default</li>
  <li>Returns the element inside of 'NodeB' if it is not empty.</li>
  </ul>
  
  <p>Here is some sample XML so that my target structure can be clearly seen (I am using MS InfoPath):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;?mso-infoPathSolution solutionVersion="1.0.0.10" productVersion="14.0.0" PIVersion="1.0.0.0" href="file:///C:\Documents%20and%20Settings\Chris\Local%20Settings\Application%20Data\Microsoft\InfoPath\Designer3\9016384cab6148f6\manifest.xsf" ?&gt;&lt;?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?&gt;
  &lt;my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-09-07T14:19:10" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us"&gt;
  &lt;my:NodeASection&gt;
      &lt;my:NodeA&gt;2012-09-13&lt;/my:NodeA&gt;
  &lt;/my:NodeASection&gt;
      &lt;my:NodeBSection&gt;
          &lt;my:NodeBGroup&gt;
              &lt;my:NodeB&gt;2012-09-14&lt;/my:NodeB&gt;
          &lt;/my:NodeBGroup&gt;
      &lt;/my:NodeBSection&gt;
  &lt;/my:myFields&gt;
  </code></pre>
  
  <p>This XPath expression can be used to evaluate NodeB for the existence of text: <code>boolean(//my:NodeB[(text())])</code></p>
  
  <p>I have heard of the "Becker Method" but I'm not sure how that applies when both nodes exist. I'm <em>very</em> new to XPath and appreciate any help that can be offered.</p>