2 // Copyright (C) 2011 Ensoftek
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // This program is the base class to implement XML writer.
15 function XmlWriterOemr($indent = ' ') {
16 $this->indent
= $indent;
17 $this->xml
= '<?xml version="1.0" encoding="utf-8"?>'."\n";
20 for ($i = 0, $j = count($this->stack
); $i < $j; $i++
) {
21 $this->xml
.= $this->indent
;
24 function push($element, $attributes = array()) {
26 $this->xml
.= '<'.$element;
27 foreach ($attributes as $key => $value) {
28 $this->xml
.= ' '.htmlspecialchars($key).'="'.htmlspecialchars($value).'"';
31 $this->stack
[] = htmlspecialchars($element);
33 function element($element, $content, $attributes = array()) {
35 $this->xml
.= '<'.$element;
36 foreach ($attributes as $key => $value) {
37 $this->xml
.= ' '.htmlspecialchars($key).'="'.htmlspecialchars($value).'"';
39 $this->xml
.= '>'.htmlspecialchars($content).'</'.htmlspecialchars($element).'>'."\n";
41 function emptyelement($element, $attributes = array()) {
43 $this->xml
.= '<'.htmlspecialchars($element);
44 foreach ($attributes as $key => $value) {
45 $this->xml
.= ' '.htmlspecialchars($key).'="'.htmlspecialchars($value).'"';
47 $this->xml
.= " />\n";
50 $element = array_pop($this->stack
);
52 $this->xml
.= "</".htmlspecialchars($element).">"."\n";