khanat-opennel-code/code/web/app/app_achievements/_AchWebParser/class/XMLfile_class.php
SirCotare 9283736c91 #1470 This is a huge update. It contains all changes we made to the system on the
official ryzom servers. I removed non open source content though. So this version
is running on live servers and works!

--HG--
branch : gsoc2012-achievements
2012-12-10 15:07:13 +01:00

74 lines
No EOL
1.7 KiB
PHP

<?php
class XMLfile {
private $ident;
private $xml;
private $curr;
function XMLfile($i) {
$this->ident = $i;
$this->xml = new XMLNode($this->ident);
$this->curr = $this->xml;
}
function getIdent() {
return $this->ident;
}
function addXML($name,$attrs,$open) {
if($open == true) {
if($name == "__KEY__") {
$x = explode(".",$attrs["VALUE"]);
if(sizeof($x) > 1) {
$v = $x[1];
$a = array("sheetid"=>$attrs["VALUE"]);
}
else {
$v = $attrs["VALUE"];
$a = array();
}
$this->curr = new XMLNode($v,null,$this->curr);
foreach($a as $key=>$elem) {
$this->curr->addArg($key,$elem);
}
$tmp = $this->curr->getParent();
$tmp->addChild($this->curr);
}
elseif($name == "__VAL__") {
$this->curr->setValue($attrs["VALUE"]);
}
else {
$this->curr = new XMLNode($name,null,$this->curr);
if(isset($attrs["VALUE"])) {
$this->curr->addArg("value",$attrs["VALUE"]);
}
$tmp = $this->curr->getParent();
$tmp->addChild($this->curr);
}
}
else {
if($name == "__KEY__") {
// do nothing
}
elseif($name == "__VAL__") {
$this->curr = $this->curr->getParent();
}
elseif($name == $this->curr->getName()) {
if($this->curr->getArg("value") !== null) {
$this->curr->setValue($this->curr->getArg("value"));
$this->curr->clearArg("value");
}
$this->curr = $this->curr->getParent();
}
else {
$this->curr = $this->curr->getParent();
}
}
}
function generate($i) {
return $this->xml->generate($i);
}
}
?>