title: Php Xpath - How to get two information in a child node
body: <p>How can I get the following information in xpath?</p>
  
  <p>Text 01 - link_1.com</p>
  
  <p>Text 02 - link_2.com</p>
  
  <pre><code>$page = '
  &lt;div class="news"&gt;
  &lt;div class="content"&gt;
      &lt;div&gt;
      &lt;span class="title"&gt;Text 01&lt;/span&gt;
      &lt;span class="link"&gt;link_1.com&lt;/span&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="content"&gt;
      &lt;div&gt;
      &lt;span class="title"&gt;Text 02&lt;/span&gt;
      &lt;span class="link"&gt;link_2.com&lt;/span&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;';
  @$this-&gt;dom-&gt;loadHTML($page);
  $xpath = new DOMXPath($this-&gt;dom);
  
  // perform step #1
  $childElements = $xpath-&gt;query("//*[@class='content']");
  $lista = '';
  foreach ($childElements as $child) {
      // perform step #2
      $textChildren = $xpath-&gt;query("//*[@class='title']", $child);
      foreach ($textChildren as $n) {
          echo $n-&gt;nodeValue.'&lt;br&gt;';
      }
  
      $linkChildren = $xpath-&gt;query("//*[@class='link']", $child);
      foreach ($linkChildren as $n) {
          echo $n-&gt;nodeValue.'&lt;br&gt;';
      }
  }
  </code></pre>
  
  <p>My result is returning</p>
  
  <p>Text 01</p>
  
  <p>Text 02</p>
  
  <p>link_1.com</p>
  
  <p>link_2.com</p>
  
  <p>Text 01</p>
  
  <p>Text 02</p>
  
  <p>link_1.com</p>
  
  <p>link_2.com</p>