title: Xpath select node text but exclude child node text
body: <p>I have the following XML:</p>
  
  <pre><code>&lt;topic class="Top"&gt;
      &lt;title&gt;
          Interesting Article
      &lt;/title&gt;
      &lt;subtitle&gt;
          Science &amp; Industry
          &lt;insertedText action="start"/&gt;
              Inside &amp; Out
          &lt;insertedText action="end"/&gt;
          A Profile
      &lt;/subtitle&gt;
  &lt;/topic&gt;
  </code></pre>
  
  <p>And I would like to use xpath to extract the text of the subtitle, except for the string between the two <code>&lt;insertedText&gt;</code> nodes, giving the text "Science &amp; Industry A Profile".</p>
  
  <p>Here is my latest attempt but to be honest I'm stumped and realise that this does not exclude the text between the two tags! Any help would be appreciated:</p>
  
  <p><code>/topic[@class='Top']/*[local-name()='subtitle'][not(descendant::insertedText)]/text()</code></p>
  
  <p>The number of <code>&lt;insertedText&gt;</code> tags is also variable, so there may be none or multiple sets on <code>&lt;insertedText&gt;</code> tags which should be ignored.</p>
  
  <p>A further example of the type XML that might be encountered is below:</p>
  
  <pre><code>&lt;topic class="Top"&gt;
      &lt;title&gt;
          Interesting Article
      &lt;/title&gt;
      &lt;subtitle&gt;
          Science &amp; Industry
          &lt;insertedText action="start"/&gt;
              Inside &amp; Out
          &lt;insertedText action="end"/&gt;
          A Profile
          &lt;insertedText action="start"/&gt;
              An Insiders View
          &lt;insertedText action="end"/&gt;
          The Full Story
      &lt;/subtitle&gt;
  &lt;/topic&gt;
  </code></pre>
  
  <p><strong>Answer</strong></p>
  
  <p>The full answer, based on that provided by @lambo477, is as follows:</p>
  
  <pre><code>./topic[@class='top']/*[local-name()='subtitle']/text()[1]|/topic[@class='top']/*[local-name()='subtitle']/*[local-name()='insertedText'][@action='end']/following-sibling::node()[1]
  </code></pre>