API15

JRegistryFormatXML/objectToString: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: ===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. ...
 
Doxiki (talk | contribs)
No edit summary
Line 19: Line 19:
!Description
!Description
|-
|-
|  
| &$object
|  
|  
|  $object Data Source Object  
|  $object Data Source Object  

Revision as of 17:39, 25 March 2010

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]

Template:Description:JRegistryFormatXML/objectToString

Syntax

objectToString(&$object, $params)
Parameter Name Default Value Description
&$object $object Data Source Object
$params $param Parameters 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

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

<CodeExamplesForm />