note 129992 added to dom-parentnode.queryselector
| From: | kawewong@gmail.com | Date: | Wed, 22 Jan 2025 03:38:27 +0000 |
| Subject: | note 129992 added to dom-parentnode.queryselector | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221808@lists.php.net to get a copy of this message | ||
Even the document said "This is the modern, spec-compliant equivalent of DOMParentNode"
but in DOMParentNode page there is no new methods like
querySelector().
To use this method you have to use new class.
Example:
<?php
$html = <<<EOT
<div class="row">
<div class="col"><h1 id="heading"
class="col1-heading">Hello</h1></div>
<div class="col"><p class="paragraph">Hello world.</p>
</div>
EOT;
$doc = \DOM\HTMLDocument::createFromString($html, LIBXML_HTML_NOIMPLIED);
$elem = $doc->querySelector('#heading');
echo $elem->getAttribute('class');// result is col1-heading
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 184.22.231.131)
----
Manual Page -- https://php.net/manual/en/dom-parentnode.queryselector.php
Edit -- https://main.php.net/note/edit/129992
Del: integrated -- https://main.php.net/note/delete/129992/integrated
Del: useless -- https://main.php.net/note/delete/129992/useless
Del: bad code -- https://main.php.net/note/delete/129992/bad+code
Del: spam -- https://main.php.net/note/delete/129992/spam
Del: non-english -- https://main.php.net/note/delete/129992/non-english
Del: in docs -- https://main.php.net/note/delete/129992/in+docs
Del: other reasons-- https://main.php.net/note/delete/129992
Reject -- https://main.php.net/note/reject/129992
Search -- https://main.php.net/manage/user-notes.php