From c91e90406bbc81f8311a1d2707dd141d150f99a4 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 17 Nov 2008 00:30:18 +0000 Subject: Add output formats to our REST controllers. Add support for JSON and XML to the comment controllers as a proof of concept. It's not fully baked; we should examine ways to create helpers to make this process easier. --- core/helpers/xml.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 core/helpers/xml.php (limited to 'core/helpers') diff --git a/core/helpers/xml.php b/core/helpers/xml.php new file mode 100644 index 00000000..2700b5ae --- /dev/null +++ b/core/helpers/xml.php @@ -0,0 +1,35 @@ +\n"; + foreach ($array as $key => $value) { + if (is_array($value)) { + $xml .= xml::to_xml($value, array_slice($element_names, 1)); + } else if (is_object($value)) { + $xml .= xml::to_xml($value->as_array(), array_slice($element_names, 1)); + } else { + $xml .= "<$key>$value\n"; + } + } + $xml .= "\n"; + return $xml; + } +} -- cgit v1.2.3