title: php scrape and output everything that has a type of tag, h1, p, etc
body: <p>I'm close to knowing how to do this, but I only know how to grab specific things from a given h1 tag named _____ for ex. I'm quite new to php, so I'm not totally sure how to rig it. What I'd like to see if I can figure out, is for a random website, how to scrape and output EVERYTHING with for ex, an h1 tag. </p>
  
  <p>This is what I'm able to do so far. It probably just requires a small modification. Thoughts? Thank you.</p>
  
  <p>this scrapes everything from an &lt; a > tag named "world-market". What I can't quite figure out without breaking the code, is how to simply output ANYTHING in a &lt; a > tag</p>
  
  <pre><code>&lt;?php 
  
   $doc = new DOMDocument;
  
  // foriegn stocks
   $doc-&gt;preserveWhiteSpace = false;
  
  
   $doc-&gt;strictErrorChecking = false;
    $doc-&gt;recover = true;
  
   $doc-&gt;loadHTMLFile('http://www.money.cnn.com/data/markets/');
  
   $xpath = new DOMXPath($doc);
  
    $query = "//a[@class='world-market']";
  
    $entries = $xpath-&gt;query($query);
   foreach ($entries as $entry) {
   echo trim($entry-&gt;textContent);  // use `trim` to eliminate spaces
   }
  
   ?&gt;
  </code></pre>