title: xpath and extracting multiple values
body: <p>In my continuing saga of xpath and and extracting data I continue to struggle. I need just two values contained in a table cell. I can get to each individually, but I cannot access the other while there. I have cell's like so</p>
  
  <pre><code>&lt;TR&gt;
  &lt;TD width="120" align="center" valign="top"&gt;
  &lt;A href="http://www..yadayada.com"&gt; &lt;!--the href I need to extract--&gt;
  &lt;IMG src="http://images.com/items/yada.gif" width="80" height="80" border="1"&gt;&lt;/A&gt;
  &lt;BR&gt;
  &lt;B&gt;Random number PT&lt;/B&gt;&lt;!--the text I need to extract--&gt;
  &lt;/TD&gt;
  </code></pre>
  
  <p>I traverse like so:</p>
  
  <pre><code>@$dom = new DOMDocument();
  @$dom-&gt;loadHTML( $rawPage );
  @$xpath = new DOMXPath( $dom );
  @$queryResult = $xpath-&gt;query( "..../tr/td[contains( b, 'PT' ) ]/b" );
  </code></pre>
  
  <p>to get to the href link and similary,</p>
  
  <pre><code>@$queryResult = $xpath-&gt;query( "..../tr/td[contains( b, 'PT' ) ]/a" );
  </code></pre>
  
  <p>to get the text I need. And then I extract like so</p>
  
  <pre><code>//for the text in b
  foreach ( $queryResult as $result )
  {
  echo $result-&gt;textContent . " text content&lt;br&gt;";
  }
  </code></pre>
  
  <p>and for the link</p>
  
  <pre><code>//for the text in href
  foreach ( $queryResult as $result )
  {
  echo $result-&gt;getAttribute( 'href' ) . " href&lt;br&gt;";
  }
  </code></pre>
  
  <p>I do not pull each TD in the table and that's why I match <code>/td[contains( b, 'PT' ) ]</code> ones that have PT in the <b></b>. I've read about unions and using <code>/td[contains( b, 'PT' ) ]/*[self::a or self::b</code> but my for each errors with <code>Invalid argument supplied for foreach()</code></p>
  
  <p>I've tried using nextSibling and all that too and it just is blank when I echo it. So, how can I get the two values out of my tables?</p>