fork download
  1. <?php
  2.  
  3. $result = <<<DATA
  4. <body>
  5. <a class="secondary-header-action" href="/subscribers" role="menuitem">
  6. <span class="nav-text">Some text here</span>
  7. </a>
  8. </body>
  9. DATA;
  10.  
  11. $dom = new DOMDocument('1.0', 'UTF-8');
  12. $dom->loadHTML($result, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
  13.  
  14. $xpath = new DOMXPath($dom);
  15. $atags = $xpath->query('//a[@class="secondary-header-action"]/span[@class="nav-text"]');
  16. $res = array();
  17.  
  18. foreach($atags as $a) {
  19. array_push($res, $a->nodeValue);
  20. }
  21.  
  22. print_r($res);
Success #stdin #stdout 0.01s 52488KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Some text here
)