This project demonstrates usage of the new DOM\HTMLDocument
class introduced in PHP 8.4+. It shows how to parse and extract parts of an HTML document using native DOM manipulation.
- PHP 8.4+ with DOM extension enabled
- Composer (for autoloading if needed)
extract_head.php
— prints the first element inside<head>
extract_title.php
— extracts the<title>
tag textlist_meta.php
— lists all<meta>
tags in<head>
html/sample.html
— test HTML file
php examples/extract_head.php
php examples/extract_title.php
php examples/list_meta.php
Make sure the current working directory structure is correct:
project-root/
├── examples/
│ ├── extract_head.php
│ ├── extract_title.php
│ └── list_meta.php
├── html/
│ └── sample.html
└── vendor/
└── autoload.php
Note: These examples assume you're running PHP 8.4+ with native DOM\HTMLDocument support.