Jump to content

[SOLVED] Parsing HTML Title Tag With DOM


jjacquay712

Recommended Posts

I am trying to extract the data in the title tag using php's DOM parser. Any idea how to do this? This is what i have so far:

 

<?php
$html = "<html><head><title>Test Page</title></head><body><p>Test</p></body></html>";

$page = new DOMDocument;
$page->loadHTML($html);

$head = $page->getElementsByTagName('head'); 
$title = $head->item(0)->getElementsByTagName('title'); 
print_r($title)
?>

Link to comment
https://forums.phpfreaks.com/topic/152615-solved-parsing-html-title-tag-with-dom/
Share on other sites

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.