3D spaceshooter with online scoreboard, online demos, ship building. Now entirely defunct, but might be resurrected

class.SimpleDocument.php 869B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. # Class for easier XML generation
  3. class SimpleDocument extends DOMDocument{
  4. private $rootNode = null;
  5. public function __construct($rootName='xml', $attribs = array()){
  6. parent::__construct('1.0', 'UTF-8');
  7. $rootElement = $this->createElement($rootName, $attribs);
  8. $this->rootNode = $this->appendChild($rootElement);
  9. }
  10. public function createAttribute($name, $value){
  11. $a = parent::createAttribute($name);
  12. $a->value = $value;
  13. return $a;
  14. }
  15. public function createElement($name='element', $attribs = null, $inner=''){
  16. $elem = parent::createElement($name,$inner);
  17. if($attribs != null){
  18. foreach($attribs as $key => $value){
  19. $a = $this->createAttribute($key, $value);
  20. $elem->appendChild($a);
  21. }
  22. }
  23. return $elem;
  24. }
  25. public function appendChildToRoot(DOMElement $element){
  26. return $this->rootNode->appendChild($element);
  27. }
  28. }