Problems Parsing XML

i have a php script which parses data into an xml file using child nodes (rather than attributes). my problem is that it seems to replace the old data with the new data rather than just adding to or appending the old data…below is my script:


<?
$items = Array();
function start_element($parser, $name, $attrs){
 global $items;
 if($name == "item"){
  array_unshift($items, $attrs);
 }
}
function end_element ($parser, $name){}
$playlist_string = file_get_contents("featured.xml");
$parser = xml_parser_create();
xml_set_element_handler($parser, "start_element", "end_element");
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parse($parser, $playlist_string) or die("Error parsing XML document.");
print "<br />";
if($_POST['action'] == "ins"){
 array_unshift($items, Array(
    "caption" => $_POST['caption'],
    "make" => $_POST['make'],
    "model" => $_POST['model'],
    "year" => $_POST['year']));
 
 $items_final = $items;
}else if($_POST['action'] == "del"){
 $items_final = Array();
 foreach($items as $item){
  if($item['make'] != $_POST['make']){
   array_unshift($items_final, $item);
  }
 }
}
$write_string .= "<items>";
$write_string .= "<item>";
foreach($items_final as $item){
 $write_string .= "<caption>".$item[caption]."</caption>
";
 $write_string .= "<make>".$item[make]."</make>
";
 $write_string .= "<model>".$item[model]."</model>
";
 $write_string .= "<year>".$item[year]."</year>
";
}
$write_string .= "</item>";
$write_string .= "</items>";
 
$fp = fopen("featured.xml", "w+");
fwrite($fp, $write_string) or die("Error writing to file");
fclose($fp);
echo "<em>vehicle inserted or deleted successfully!</em><br />";
?> 

which outputs the following xml, including the duplicate end tags that came outta nowhere (bolded):


[COLOR=black]<items>[/COLOR]
[COLOR=black]<item>[/COLOR]
[COLOR=black]<caption>**1**</caption> [/COLOR]
[COLOR=black]<make>**1111**</make> [/COLOR]
[COLOR=black]<model>**1**</model> [/COLOR]
[COLOR=black]<year>**1**</year> [/COLOR]
**[COLOR=black]<caption /> [/COLOR]**
**[COLOR=black]<make /> [/COLOR]**
**[COLOR=black]<model /> [/COLOR]**
[COLOR=black]**<year />** [/COLOR]
[COLOR=black]</item>[/COLOR]
[COLOR=black]</items>[/COLOR]
 

not sure exactly where my script is failing me…any help is appreciated!!!