<?php
class parseXML implements Iterator {
private $position;
private $xml;
public $item;
public function __construct() {
$this->position = 0;
$this->xml = simplexml_load_file('project.xml');
}
public function unsetItem() {
foreach ($this as $key => $value) {
if ($value->value == $this->item ) {
unset($this->xml->data->item[$key]);
}
}
$this->mkXML();
}
public function mkXML() {
file_put_contents('project.xml', $this->xml->asXML() );
}
function rewind() {
$this->position = 0;
}
function current() {
return $this->xml->data->item[$this->position];
}
function key() {
return $this->position;
}
function next() {
++$this->position;
}
function valid() {
return isset($this->xml->data->item[$this->position]);
}
}
$itemRemove = new parseXML();
$itemRemove->item = "one";
$itemRemove->unsetItem();
?>