<?php
class XMLLinker
{
private $dom;
private $_file;
private $root;
private $link;
private $_name;
private $_place;
private $_position;
private $_link;
private $i = 0;
public function __construct($file){
$this->dom = new DOMDocument('1.0', 'UTF-8');
$this->root = $this->dom->appendChild(new DOMElement('root'));
$this->_file = $file;
if(!file_exists($this->_file)){
$this->dom->save($this->_file);
}
}
public function CreateLinks($place, $position, $link, $name){
$this->_place = $place;
$this->_position = $position;
$this->_link = $link;
$this->_name = $name;
$this->link = $this->root->appendChild(new DOMElement('link', $this->_name));
$this->link->appendChild(new DOMAttr('id', $this->i++));
$this->link->appendChild(new DOMAttr('place', $this->_place));
$this->link->appendChild(new DOMAttr('position', $this->_position));
$this->link->appendChild(new DOMAttr('link', $this->_link));
$this->dom->save($this->_file);
}
}
$n = new XMLLinker('links.xml');
$n->CreateLinks("1", "2", "?act=idxx", "Home2");
?>