9283736c91
official ryzom servers. I removed non open source content though. So this version is running on live servers and works! --HG-- branch : gsoc2012-achievements
77 lines
No EOL
1.4 KiB
PHP
77 lines
No EOL
1.4 KiB
PHP
<?php
|
|
class XMLNode {
|
|
private $name;
|
|
private $value = null;
|
|
private $args = array();
|
|
private $children = array();
|
|
private $parent = null;
|
|
|
|
function XMLNode($n = null,$v = null,$p = null) {
|
|
$this->name = $n;
|
|
$this->value = $v;
|
|
$this->parent = $p;
|
|
}
|
|
|
|
function getParent() {
|
|
return $this->parent;
|
|
}
|
|
|
|
function getName() {
|
|
return $this->name;
|
|
}
|
|
|
|
function setName($n) {
|
|
$this->name = $n;
|
|
}
|
|
|
|
function setValue($v) {
|
|
$this->value = $v;
|
|
}
|
|
|
|
function addArg($k,$v) {
|
|
$this->args[$k] = $v;
|
|
}
|
|
|
|
function getArg($k) {
|
|
return $this->args[$k];
|
|
}
|
|
|
|
function clearArg($k) {
|
|
unset($this->args[$k]);
|
|
}
|
|
|
|
function addChild($c) {
|
|
$this->children[] = $c;
|
|
}
|
|
|
|
function generate($indent) {
|
|
$xml = "";
|
|
#for($i=0;$i<$indent;$i++) {
|
|
$xml .= $indent;
|
|
#}
|
|
$xml .= "<".strtolower($this->name);
|
|
foreach($this->args as $key=>$elem) {
|
|
$xml .= ' '.strtolower($key).'="'.$elem.'"';
|
|
}
|
|
|
|
if(sizeof($this->children) > 0) {
|
|
$xml .= ">\n";
|
|
foreach($this->children as $elem) {
|
|
$xml .= $elem->generate($indent.' ');
|
|
}
|
|
#for($i=0;$i<$indet;$i++) {
|
|
$xml .= $indent;
|
|
#}
|
|
$xml .= "</".strtolower($this->name).">\n";
|
|
}
|
|
elseif($this->value !== null) {
|
|
$xml .= ">".$this->value."</".strtolower($this->name).">\n";
|
|
}
|
|
else {
|
|
$xml .= " />\n";
|
|
}
|
|
|
|
return $xml;
|
|
}
|
|
}
|
|
?>
|