note 30324 deleted from function.domnode-set-content by sobak

From: Date: Tue, 22 Nov 2016 03:40:25 +0000
Subject: note 30324 deleted from function.domnode-set-content by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207397@lists.php.net to get a copy of this message
Note Submitter: ericb at computer dot org ---- Actually, don't forget that the text is actually a child node of the given element. The domxml coders decided to append to the content in the case that this function is called on a node which has children (to avoid a crash), but you shouldn't normally call it that way. For example, if your document had: <contact> <name>Eric</name> </contact> and you wanted to change the content of the name element and $contact is the contact node, then you would use: $names = $contact->get_elements_by_tagname("name"); $name = $names[0]; $name_text_node = $name->first_child(); $name_text_node->set_content("Joe"); Hope this clarifies things. Removing nodes, and inserting new ones is not an efficient solution :) Cheers, Eric

« previous php.notes (#207397) next »