In PHP, I want to parse an HTML page and get the identifiers of certain elements. I can get all the elements, but I can not get the identifiers.
$doc = new DOMDocument(); $doc->loadHTML('<html><body><h3 id="h3-elem-id">A</h3></body></html>'); $divs = $doc->getElementsByTagName('h3'); foreach($divs as $n) { (...) }
Is there a way to get the item id?
Thanks.
source share