note 57204 added to function.dom-domdocument-loadhtmlfile
| From: | LachlanHunt at osu1 dot php dot net | Date: | Tue, 27 Sep 2005 06:15:13 +0000 |
| Subject: | note 57204 added to function.dom-domdocument-loadhtmlfile | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-95851@lists.php.net to get a copy of this message | ||
Andy, the code you gave should not give that result. In your code, $tag is an <a> element and
the nodeValue of elements is null, according to the DOM2 spec. You need to get at the text node
first, before getting the node value.
<?
...
foreach ($tags as $tag) {
echo $tag->getAttribute('href').' |
'.$tag->childNodes->item(0)->nodeValue."\n";
}
?>
This should output:
/mypage1 | Hello World!
/mypage2 | Another Hello World!
----
Manual Page -- http://www.php.net/manual/en/function.dom-domdocument-loadhtmlfile.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57204
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57204&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57204&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57204&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57204&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57204&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57204&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57204&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57204&report=yes
Search -- http://master.php.net/manage/user-notes.php