fork(1) download
  1. <?php
  2.  
  3. $html = <<< LOL
  4. <a class="js-publication" href="publication/247931167">
  5.   <span class="publication-title">An approach for textual authoring</span>
  6. </a>
  7. LOL;
  8.  
  9. $dom = new DOMDocument();
  10. $dom->loadHTML($html);
  11. $xpath = new DOMXpath($dom);
  12. foreach ($xpath->query("//a[@class='js-publication']") as $sText){
  13. echo $sText->textContent;
  14. echo $sText->getAttribute('href');
  15. }
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
 
    An approach for textual authoring 
publication/247931167