note 113191 added to domdocument.importnode

From: Date: Wed, 11 Sep 2013 01:54:09 +0000
Subject: note 113191 added to domdocument.importnode
Groups: php.notes 
Request: Send a blank email to php-notes+get-196218@lists.php.net to get a copy of this message
Поведение функции importNode($node, false) различно в PHP 5.2.9-2 и в PHP 5.2.17. Второй параметр явно устанавливаем равным false. В PHP 5.2.9-2 importNode() импортирует элементы БЕЗ атрибутов. В PHP 5.2.17 элементы импортируются ВМЕСТЕ со своими атрибутами. The behavior of importNode($node, false) is different in PHP 5.2.9-2 and PHP 5.2.17. The second option is explicitly set to false. In PHP 5.2.9-2 importNode() imports the elements WITHOUT attributes. In PHP 5.2.17 the elements imported ALONG with their attributes. <?php $xml=" <html> <a href='yandex.com'>Yandex.com</a> <a href='rik.dn.ua'>RiK.dn.ua</a> </html> "; $doc=new domDocument('1.0'); $doc->loadXML($xml); $list=$doc->getElementsByTagName('a'); $doc1=new domDocument('1.0'); $doc1->formatOutput=true; for($i=0; $i<$list->length; $i++) $doc1->appendChild($doc1->importNode($list->item($i), false)); $doc1->save('file.xml'); ?> file.xml PHP 5.2.9-2 <?xml version="1.0"?> <a/> <a/> file.xml PHP 5.2.17 <?xml version="1.0"?> <a href="yandex.com"/> <a href="rik.dn.ua"/> ---- Server IP: 193.19.243.212 Probable Submitter: 193.19.243.212 (proxied: 178.216.123.184) ---- Manual Page -- http://php.net/manual/en/domdocument.importnode.php Edit -- https://master.php.net/note/edit/113191 Del: integrated -- https://master.php.net/note/delete/113191/integrated Del: useless -- https://master.php.net/note/delete/113191/useless Del: bad code -- https://master.php.net/note/delete/113191/bad+code Del: spam -- https://master.php.net/note/delete/113191/spam Del: non-english -- https://master.php.net/note/delete/113191/non-english Del: in docs -- https://master.php.net/note/delete/113191/in+docs Del: other reasons-- https://master.php.net/note/delete/113191 Reject -- https://master.php.net/note/reject/113191 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196218) next »