note 99716 added to domdocument.getelementsbytagname

From: Date: Wed, 01 Sep 2010 10:17:19 +0000
Subject: note 99716 added to domdocument.getelementsbytagname
Groups: php.notes 
Request: Send a blank email to php-notes+get-172229@lists.php.net to get a copy of this message
Note that when using getElementsByTagName that it is a dynamic list. Thus if you have code which adjusts the DOM structure it will change the results of the getElementsByTagName results list. The following code iterates through a complete set of results and changes them all to a new tag: <?php $nodes = $xml->getElementsByTagName ("oldtag"); $nodeListLength = $nodes->length; // this value will also change for ($i = 0; $i < $nodeListLength; $i ++) { $node = $nodes->item(0); // some code to change the tag name from "oldtag" to something else // e.g. encrypting a tag element } ?> Since the list is dynamically updating, $nodes->item(0) is the next "unchanged" tag. ---- Server IP: 69.147.83.197 Probable Submitter: 41.213.126.5 (proxied: 41.56.36.210) ---- Manual Page -- http://www.php.net/manual/en/domdocument.getelementsbytagname.php Edit -- https://master.php.net/note/edit/99716 Del: integrated -- https://master.php.net/note/delete/99716/integrated Del: useless -- https://master.php.net/note/delete/99716/useless Del: bad code -- https://master.php.net/note/delete/99716/bad+code Del: spam -- https://master.php.net/note/delete/99716/spam Del: non-english -- https://master.php.net/note/delete/99716/non-english Del: in docs -- https://master.php.net/note/delete/99716/in+docs Del: other reasons-- https://master.php.net/note/delete/99716 Reject -- https://master.php.net/note/reject/99716 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172229) next »