From: Mikael Nordfeldth Date: Thu, 27 Nov 2014 12:36:29 +0000 (+0100) Subject: Namespaced elements now available in xmloutputter X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a3ded586b6a0bbc28b0441b129d0befb8d6e4006;p=quix0rs-gnu-social.git Namespaced elements now available in xmloutputter --- diff --git a/lib/xmloutputter.php b/lib/xmloutputter.php index 528f633050..481b2dedca 100644 --- a/lib/xmloutputter.php +++ b/lib/xmloutputter.php @@ -142,6 +142,15 @@ class XMLOutputter $this->elementEnd($tag); } + function elementNS(array $ns, $tag, $attrs=null, $content=null) + { + $this->elementStartNS($ns, $tag, $attrs); + if (!is_null($content)) { + $this->xw->text($content); + } + $this->elementEnd($tag); + } + /** * output a start tag for an element * @@ -169,6 +178,20 @@ class XMLOutputter } } + function elementStartNS(array $ns, $tag, $attrs=null) + { + reset($ns); // array pointer to 0 + $uri = key($ns); + $this->xw->startElementNS($ns[$uri], $tag, $uri); + if (is_array($attrs)) { + foreach ($attrs as $name => $value) { + $this->xw->writeAttribute($name, $value); + } + } else if (is_string($attrs)) { + $this->xw->writeAttribute('class', $attrs); + } + } + /** * output an end tag for an element *