3 homepage: http://arc.semsol.org/
4 license: http://arc.semsol.org/license
6 class: ARC2 Legacy XML Serializer
7 author: Benjamin Nowack
13 class ARC2_LegacyXMLSerializer extends ARC2_Class {
15 function __construct($a = '', &$caller) {
16 parent::__construct($a, $caller);
19 function ARC2_LegacyXMLSerializer($a = '', &$caller) {/* ns */
20 $this->__construct($a, $caller);
25 $this->content_header = 'text/xml';
30 function getSerializedArray($struct, $root = 1, $ind = ' ') {
33 $is_flat = $this->isAssociativeArray($struct) ? 0 : 1;
34 foreach ($struct as $k => $v) {
35 $tag = $is_flat ? 'item' : preg_replace('/[\s]/s', '_', $k);
36 $tag = preg_replace('/^.*([a-z0-9\-\_]+)$/Uis', '\\1', $tag);
37 $r .= $n . $ind . '<' . $tag . '>' . (is_array($v) ? $this->getSerializedArray($v, 0, $ind . ' ') . $n . $ind : htmlspecialchars($v)) . '</' . $tag . '>';
39 if ($root) $r = $this->getHead() . $r . $this->getFooter();
47 $r = '<?xml version="1.0"?>';
52 function getFooter() {
60 function isAssociativeArray($v) {
61 foreach (array_keys($v) as $k => $val) {
62 if ($k !== $val) return 1;