DOM append to the top

From: Date: Fri, 20 Nov 2009 10:23:41 +0000
Subject: DOM append to the top
Groups: php.general 
Request: Send a blank email to php-general+get-299956@lists.php.net to get a copy of this message
Yo! I have a working form that adds user input to an XML file, it adds the new "item" element to the bottom of the list of previously created "item" elements. I would now like the new elements to be added to the top of the list. So far i've tried using: insertBefore() but i'm still getting elements added to the bottom. The XML looks like: <Clothes> <Item>...</Item> <Item>...</Item> <Item>...</Item> <----- new items are added here <Clothes> This is what my code looks like: $y = $dom -> getElementsByTagName("item"); $dom -> documentElement -> insertBefore($Xitem,$y); If trying to pass the top most "item" node to insertbefore() but without any luck. Any ideas ? Cheers Mongoose

« previous php.general (#299956) next »