From eaae4562228bcbf780329d7bbb5f35437b31ebe3 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 12 Feb 2009 08:38:43 -0500 Subject: Add XMLStringer for building XML strings We had a bunch of --- lib/xmlstringer.php | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 lib/xmlstringer.php (limited to 'lib/xmlstringer.php') diff --git a/lib/xmlstringer.php b/lib/xmlstringer.php new file mode 100644 index 000000000..951b13b67 --- /dev/null +++ b/lib/xmlstringer.php @@ -0,0 +1,68 @@ +. + * + * @category Output + * @package Laconica + * @author Evan Prodromou + * @copyright 2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +/** + * Create in-memory XML + * + * @category Output + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * @see Action + * @see HTMLOutputter + */ + +class XMLStringer extends XMLOutputter +{ + function __construct($indent=false) + { + $this->xw = new XMLWriter(); + $this->xw->openMemory(); + $this->xw->setIndent($indent); + } + + function getString() + { + return $this->xw->outputMemory(); + } + + // utility for quickly creating XML-strings + + static function estring($tag, $attrs=null, $content=null) + { + $xs = new XMLStringer(); + $xs->element($tag, $attrs, $content); + return $xs->getString(); + } +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf