MkFramework
 All Data Structures Functions
plugin_xmlObject.php
1 <?php
2 /*
3 This file is part of Mkframework.
4 
5 Mkframework is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License.
8 
9 Mkframework is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13 
14 You should have received a copy of the GNU Lesser General Public License
15 along with Mkframework. If not, see <http://www.gnu.org/licenses/>.
16 
17 */
24 
25  private $oObject;
26  private $tColumn;
27  private $sEncoding;
28  private $sRootName;
29 
30  private $sXml;
31 
37  public function __construct($oObject){
38  $this->oObject=$oObject;
39 
40  $this->sEncoding='UTF-8';
41 
42  $this->sRootName='root';
43  }
49  public function setEncoding($sEncoding){
50  $this->sEncoding=$sEncoding;
51  }
57  public function setRootName($sRootName){
58  $this->sRootName=$sRootName;
59  }
65  public function setListColumn($tColumn){
66  $this->tColumn=$tColumn;
67  }
72  public function show(){
73 
74  header ("Content-Type:text/xml");
75 
76  echo $this->build();
77 
78  exit;
79  }
85  public function build(){
86  $this->sXml.='<?xml version="1.0" encoding="'.$this->sEncoding.'"?>';
87 
88  $this->open($this->sRootName);
89  foreach($this->tColumn as $sColumn){
90  $this->add($sColumn,$this->oObject->$sColumn);
91  }
92  $this->close($this->sRootName);
93 
94  return $this->sXml;
95  }
96 
97  private function add($sTag,$sValue){
98  $this->sXml.='<'.$sTag.'><![CDATA['.$sValue.']]></'.$sTag.'>';
99  }
100 
101  private function open($sTag){
102  $this->sXml.='<'.$sTag.'>';
103  }
104  private function close($sTag){
105  $this->sXml.='</'.$sTag.'>';
106  }
107 
108 }
setRootName($sRootName)
setEncoding($sEncoding)