Dom element of paragraph's text
<p>I'm making a web scraper and this is driving me crazy!</p>

<p>I need to get the text of a paragraph. Simple, right?! Here's the code.</p>

<pre><code>$xpath = new DOMXPath($dom);
$hrefs = $xpath-&gt;evaluate("/html/body//div");

for ($i = 0; $i &lt; $hrefs-&gt;length; $i++) {
 $href = $hrefs-&gt;item($i);
 $url = $href-&gt;getAttribute('class');
 echo "&lt;br /&gt;Found it: $url";
}
</code></pre>

<p>It works perfectly, grabs the class of every div on the page and echoes it out. But what I really need to do is find all <code>&lt;p&gt;</code> tags - every one on the page - and echo the text that is in between the <code>&lt;p&gt;</code>! I have a feeling it's simple but I just can't figure it out.</p>

<p><strong>edit</strong></p>

<p>All it took was the following:</p>

<pre><code>$doc = new DOMDocument();
@$doc-&gt;loadHTML($html);
$node = $doc-&gt;getElementsByTagName('p')-&gt;item(3);
echo $node-&gt;textContent."\n";
</code></pre>

<p>What you really want is getElementsByName and then once you have the node, you textContent for the win. Thanks folks! Not sure if it will apply to everyone else's situation, but it sure does mine. =o</p>
