Jump to content

Finding the tagname of a DOM element in PHP


HarryHuy

Recommended Posts

I want to iterate through each element on an html page and echo each element's name. I thought this should work:

 


$tags = $doc->getElementsByTagName('*');
 
foreach ($tags as $tag) {
      echo $tag->tagname;
}

 

but I am getting the error:

 


Notice: Undefined property: DOMElement::$tagname in C:\...\ on line 51

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.