peeps Posted October 1, 2008 Share Posted October 1, 2008 I was trying to read in a web page from another site and all I want to look at is the div tag with a certain id. I am able to get the element by using echo $dom->getElementById('menubox')->tagName; but all that tells me is that its a div tag. How do I print out what is in that div tag? $dom = new DOMDocument; $dom->validateOnParse = true; @$dom->loadHTMLFile("myFileSomewhere.html"); echo $dom->getElementById('menubox')->tagName; Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/126644-solved-dom-help-getelementbyid/ Share on other sites More sharing options...
discomatt Posted October 1, 2008 Share Posted October 1, 2008 http://php.net/manual/en/class.domelement.php Doesn't look like you can. Link to comment https://forums.phpfreaks.com/topic/126644-solved-dom-help-getelementbyid/#findComment-654910 Share on other sites More sharing options...
sasa Posted October 1, 2008 Share Posted October 1, 2008 try echo $dom->getElementById('menubox')->textContent; Link to comment https://forums.phpfreaks.com/topic/126644-solved-dom-help-getelementbyid/#findComment-654946 Share on other sites More sharing options...
peeps Posted October 2, 2008 Author Share Posted October 2, 2008 That works wonders thanks so much. Link to comment https://forums.phpfreaks.com/topic/126644-solved-dom-help-getelementbyid/#findComment-655330 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.