note 30324 added to function.domnode-set-content
| From: | ericb at computer dot org | Date: | Fri, 14 Mar 2003 04:18:19 +0000 |
| Subject: | note 30324 added to function.domnode-set-content | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45284@lists.php.net to get a copy of this message | ||
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
--
http://www.php.net/manual/en/function.domnode-set-content.php
http://master.php.net/manage/user-notes.php?action=edit+30324
http://master.php.net/manage/user-notes.php?action=delete+30324
http://master.php.net/manage/user-notes.php?action=reject+30324