title: Why is XPath unclean constructed? Why is text() not needed in predicate?
body: <p>Assume I have:</p>
  
  <pre><code>&lt;A&gt;
    &lt;B&gt;C&lt;/B&gt;
    &lt;D&gt;E&lt;/D&gt;
  &lt;/A&gt;
  </code></pre>
  
  <p>Then I can output the B-element (including tags) with:</p>
  
  <pre><code>//B
  </code></pre>
  
  <p>Which will return </p>
  
  <pre><code>&lt;B&gt;C&lt;/B&gt;
  </code></pre>
  
  <p><strong>But why is text() not needed in a predicate?</strong>  The following 2 lines give the same output:</p>
  
  <pre><code>/A[B = 'C']/D
  /A[B/text() = 'C']/D
  </code></pre>
  
  <p>If XPATH was cleanly constructed I would expect it would be (or in some kind of other element structure):</p>
  
  <pre><code>/A[B = &lt;B&gt;C&gt;&lt;/B&gt;]/D
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>/A[B/text()='C']/D
  </code></pre>
  
  <p><strong>Can someone give me a rationale why text() is needed for output, but it is not needed for predicates?</strong> </p>