title: XPath Node to String
body: <p>How can I select the string contents of the following nodes:</p>
  
  <pre><code>&lt;span class="url"&gt;
   word
   &lt;b class=" "&gt;test&lt;/b&gt;
  &lt;/span&gt;
  
  &lt;span class="url"&gt;
   word
   &lt;b class=" "&gt;test2&lt;/b&gt;
   more words
  &lt;/span&gt;
  </code></pre>
  
  <p>I have tried a few things</p>
  
  <pre><code>//span/text()
  </code></pre>
  
  <p>Doesn't get the bold tag</p>
  
  <pre><code>//span/string(.)
  </code></pre>
  
  <p>is invalid</p>
  
  <pre><code>string(//span)
  </code></pre>
  
  <p>only selects 1 node</p>
  
  <p>I am using simple_xml in php and the only other option I think is to use //span which returns:</p>
  
  <pre><code>Array
  (
      [0] =&gt; SimpleXMLElement Object
          (
              [@attributes] =&gt; Array
                  (
                      [class] =&gt; url
                  )
  
              [b] =&gt; test
          )
  
      [1] =&gt; SimpleXMLElement Object
          (
              [@attributes] =&gt; Array
                  (
                      [class] =&gt; url
                  )
  
              [b] =&gt; test2
          )
  
  )
  </code></pre>
  
  <p>*note that it is also dropping the "more words" text from the second span.</p>
  
  <p>So I guess I could then flatten the item in the array using php some how? Xpath is preferred, but any other ideas would help too.</p>