JRegistryFormatXML/objectToString
From Joomla! Documentation
< API15:JRegistryFormatXML
The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
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.
Template:Description:JRegistryFormatXML/objectToString
Syntax[edit]
objectToString(&$object, $params)
Parameter Name | Default Value | Description |
---|---|---|
&$object | $object Data Source Object | |
$params | $param Parameters used by the formatter |
Returns[edit]
string XML Formatted String
Defined in[edit]
libraries/joomla/registry/format/xml.php
Importing[edit]
jimport( 'joomla.registry.format.xml' );
Source Body[edit]
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] Template:SeeAlso:JRegistryFormatXML/objectToString
Examples[edit]
<CodeExamplesForm />