Vale ahora si, más o menos es lo que había captado pero quería asegurarme.
Mírate esta respuesta, te pego una parte, supongo que es lo que quieres:
Código PHP:
$dom = new DOMDocument;
$dom->loadHTML($HTML);
$allElements = $dom->getElementsByTagName('*');
echo $allElements->length;
The above will output 8, because there is eight elements in the DOM. If you also need to know the distribution of elements, you can do
Código PHP:
$elementDistribution = array();
foreach($allElements as $element) {
if(array_key_exists($element->tagName, $elementDistribution)) {
$elementDistribution[$element->tagName] += 1;
} else {
$elementDistribution[$element->tagName] = 1;
}
}
print_r($elementDistribution);
This would return
Código PHP:
Array (
[html] => 1
[head] => 1
[title] => 1
[body] => 1
[p] => 2
[br] => 1
[img] => 1
)
http://stackoverflow.com/questions/3...gs-in-page-php
Saludos!