note 76182 added to function.dom-domelement-construct
| From: | " | Date: | Wed, 04 Jul 2007 02:17:47 +0000 |
| Subject: | note 76182 added to function.dom-domelement-construct | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128214@lists.php.net to get a copy of this message | ||
I'm just starting to get into the DOM methods and finding it pretty challenging.
One of the obstacles is that once you've got a node, there doesn't seem to be any way to
see what's inside it (at least I haven't been able to find it). You'd expect (I did)
print_r to show you the properties (attributes) of the node, but all it tells you is the object
type.
So I wrote this little function to mimic the way I think print_r should work:
<?php
function nodeDump($node)
{
$output = print_r($node, TRUE);
$output = str_replace(")\n", '', $output);
$output .= ' ' . '[tagName] => ' . $node->tagName . " \n";
$numOfAttribs = $node->attributes->length;
for ($i = 0; $i < $numOfAttribs; $i++)
{
$output .= ' [' . $node->attributes->item($i)->nodeName . '] =>
' . $node->attributes->item($i)->nodeValue . " \n";
}
$output .= ' [nodeValue] => ' . $node->nodeValue;
$output .= ')';
return $output;
}
?>
OK - to really work like print_r it would also go through all the childNodes recursively, but
it's a start.
----
Server IP: 69.147.83.197
Probable Submitter: 74.227.168.6
----
Manual Page -- http://www.php.net/manual/en/function.dom-domelement-construct.php
Edit -- https://master.php.net/note/edit/76182
Del: integrated -- https://master.php.net/note/delete/76182/integrated
Del: useless -- https://master.php.net/note/delete/76182/useless
Del: bad code -- https://master.php.net/note/delete/76182/bad+code
Del: spam -- https://master.php.net/note/delete/76182/spam
Del: non-english -- https://master.php.net/note/delete/76182/non-english
Del: in docs -- https://master.php.net/note/delete/76182/in+docs
Del: other reasons-- https://master.php.net/note/delete/76182
Reject -- https://master.php.net/note/reject/76182
Search -- https://master.php.net/manage/user-notes.php