HarryHuy Posted December 15, 2014 Share Posted December 15, 2014 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 Link to comment https://forums.phpfreaks.com/topic/293114-finding-the-tagname-of-a-dom-element-in-php/ Share on other sites More sharing options...
Ch0cu3r Posted December 15, 2014 Share Posted December 15, 2014 Line 51 should be (name starts with a capital letter) echo $tag->tagName; Variable/property names are case sensitive Link to comment https://forums.phpfreaks.com/topic/293114-finding-the-tagname-of-a-dom-element-in-php/#findComment-1499661 Share on other sites More sharing options...
HarryHuy Posted December 15, 2014 Author Share Posted December 15, 2014 Line 51 should be (name starts with a capital letter) echo $tag->tagName; Variable/property names are case sensitive Thanks a lot for the help! Link to comment https://forums.phpfreaks.com/topic/293114-finding-the-tagname-of-a-dom-element-in-php/#findComment-1499662 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.