Actions

API16

JRegistryFormatXML/objectToString

From Joomla! Documentation

< API16:JRegistryFormatXML
Revision as of 17:45, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Converts an object into an XML formatted string. If more than two levels of nested groups are necessary, since INI is not useful, XML or another format should be used.


[Edit Descripton]

Description:JRegistryFormatXML/objectToString

Syntax

objectToString($object, $params)
Parameter Name Default Value Description
$object Data source object.
$params Options used by the formatter.

Returns

string XML formatted string.

Defined in

libraries/joomla/registry/format/xml.php

Importing

jimport( 'joomla.registry.format.xml' );

Source Body

public function objectToString($object, $params)
{
        $depth = 1;
        $retval = "<?xml version=\"1.0\" ?>\n<config>\n";
        foreach (get_object_vars($object) as $key=>$item) {
                if (is_object($item)) {
                        $retval .= "\t<group name=\"".$key."\">\n";
                        $retval .= $this->_buildXMLstringLevel($item, $depth+1);
                        $retval .= "\t</group>\n";
                } else {
                        $retval .= "\t<entry name=\"".$key."\">".$item."</entry>\n";
                }
        }
        $retval .= '</config>';
        return $retval;
}

[Edit See Also] SeeAlso:JRegistryFormatXML/objectToString

Examples

<CodeExamplesForm />