note 85951 rejected from domnode.appendchild by thiago
| From: | thiago@php.net | Date: | Fri, 26 Sep 2008 00:50:23 +0000 |
| Subject: | note 85951 rejected from domnode.appendchild by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-144723@lists.php.net to get a copy of this message | ||
Note Submitter: ahmed dot rachdi at yahoo dot fr
----
how can i insert a node before the first child node?
example;
<?xml version="1.0" ?>
- <news newsTitle="Livre D'Or">
-<item>
<date>............</date>
<title>..............</title> //Firstchild item(0)
<intro>....... .</intro>
<full> ......</full>
</item>
-<item>
<date>............</date>
<title>..............</title>//Secondchild
<intro>....... .</intro>
<full> ......</full>
</item>
-<item>
<date>............</date>
<title>..............</title> //lastchild
<intro>....... .</intro>
<full> ......</full>
</item>
</news>
if i want to add an item on the bottom of the tree we use appendChild() , but if i wanted to add an
item on the top what am i gonna do? is there a function or a solution to append a node before the
first child?
thanks for help..
Result with appendchild():
<?xml version="1.0" ?>
- <news newsTitle="Livre D'Or">
-<item>
<date>............</date>
<title>..............</title> //Firstchild item(0)
<intro>....... .</intro>
<full> ......</full>
</item>
-<item>
<date>............</date>
<title>..............</title>//Secondchild
<intro>....... .</intro>
<full> ......</full>
</item>
-<item>
<date>............</date>
<title>..............</title> //lastchild
<intro>....... .</intro>
<full> ......</full>
</item>
<item>
<date>............</date>
<title>..............</title> //New child
<intro>....... .</intro>
<full> ......</full>
</item>
</news>
wished result :
<?xml version="1.0" ?>
- <news newsTitle="Livre D'Or">
-<item>
<date>............</date>
<title>..............</title> //new child
<intro>....... .</intro>
<full> ......</full>
</item>
-<item>
<date>............</date>
<title>..............</title>// Firstchild item(0)
<intro>....... .</intro>
<full> ......</full>
</item>
-<item>
<date>............</date>
<title>..............</title> //Secondchild
<intro>....... .</intro>
<full> ......</full>
</item>
<item>
<date>............</date>
<title>..............</title> //lastchild
<intro>....... .</intro>
<full> ......</full>
</item>
</news>
thnks for help..