title: php: Extract text between specific tags from a webpage
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3577641/best-methods-to-parse-html-with-php">Best methods to parse HTML with PHP</a>  </p>
  </blockquote>
  
  
  
  <p>I understand I should be using a html parser like php domdocument (<a href="http://docs.php.net/manual/en/domdocument.loadhtml.php" rel="nofollow noreferrer">http://docs.php.net/manual/en/domdocument.loadhtml.php</a>) or tagsoup.</p>
  
  <p>How would I use php domdocument to extract text between specific tags, for example get text between h1,h2,h3,p,table? It seems I can only do this for one tag only with getelementbytagname.</p>
  
  <p>Is there a better html parser for such task? Or how would I loop through the php domdocument? </p>