note 82999 added to domdocument.getelementsbytagname
| From: | enno dot julian at chello dot nl | Date: | Tue, 06 May 2008 07:35:57 +0000 |
| Subject: | note 82999 added to domdocument.getelementsbytagname | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139088@lists.php.net to get a copy of this message | ||
Here a simple tip (thanx to Salathe), to retrieve the content of the titletag from an (X)HTML file,
$doc = new DOMDocument();
$doc->validateonParse = TRUE;
@$doc->loadHTMLFile($fileDir . $file);
$title = $doc->getElementsByTagName('title')->item(0)->nodeValue;
Explanation:
getElementsByTagName returns a DOMNodeList since you're asking for any and all elements with
that particular tag. To retrieve the title, you'll have to access one of the DOMElements (the
first one since there's generally only one title element) and then ask for the value.
----
Server IP: 89.248.170.61
Probable Submitter: 77.249.62.89
----
Manual Page -- http://www.php.net/manual/en/domdocument.getelementsbytagname.php
Edit -- https://master.php.net/note/edit/82999
Del: integrated -- https://master.php.net/note/delete/82999/integrated
Del: useless -- https://master.php.net/note/delete/82999/useless
Del: bad code -- https://master.php.net/note/delete/82999/bad+code
Del: spam -- https://master.php.net/note/delete/82999/spam
Del: non-english -- https://master.php.net/note/delete/82999/non-english
Del: in docs -- https://master.php.net/note/delete/82999/in+docs
Del: other reasons-- https://master.php.net/note/delete/82999
Reject -- https://master.php.net/note/reject/82999
Search -- https://master.php.net/manage/user-notes.php