note 73211 added to function.dom-domnodelist-item
| From: | oliver dot christen at camptocamp dot com | Date: | Tue, 13 Feb 2007 15:27:15 +0000 |
| Subject: | note 73211 added to function.dom-domnodelist-item | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123322@lists.php.net to get a copy of this message | ||
NodeList are something annoying because you can't output the content with a simple print_r, so
I did a little function that add all the node to a new empty DOMDocument and output it as a string.
Have fun.
<?php
public function domNodeList_to_string($DomNodeList) {
$output = '';
$doc = new DOMDocument;
while ( $node = $DomNodeList->item($i) ) {
// import node
$domNode = $doc->importNode($node, true);
// append node
$doc->appendChild($domNode);
$i++;
}
$output = $doc->saveXML();
$output = print_r($output, 1);
// I added this because xml output and ajax do not like each others
$output = htmlspecialchars($output);
return $output;
}
?>
----
Server IP: 194.153.94.10
Probable Submitter: 128.178.82.60 (proxied: 192.168.227.21)
----
Manual Page -- http://www.php.net/manual/en/function.dom-domnodelist-item.php
Edit -- https://master.php.net/note/edit/73211
Del: integrated -- https://master.php.net/note/delete/73211/integrated
Del: useless -- https://master.php.net/note/delete/73211/useless
Del: bad code -- https://master.php.net/note/delete/73211/bad+code
Del: spam -- https://master.php.net/note/delete/73211/spam
Del: non-english -- https://master.php.net/note/delete/73211/non-english
Del: in docs -- https://master.php.net/note/delete/73211/in+docs
Del: other reasons-- https://master.php.net/note/delete/73211
Reject -- https://master.php.net/note/reject/73211
Search -- https://master.php.net/manage/user-notes.php