note 82999 deleted from domdocument.getelementsbytagname by bjori

From: Date: Tue, 06 May 2008 19:58:05 +0000
Subject: note 82999 deleted from domdocument.getelementsbytagname by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-139109@lists.php.net to get a copy of this message
Note Submitter: enno dot julian at chello dot nl Reason: useless ---- 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.

« previous php.notes (#139109) next »