API15

JRegistryFormatXML/objectToString: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
No edit summary
m removing red link to edit, no existant pages
Line 5: Line 5:


<span class="editsection" style="font-size:76%;">
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JRegistryFormatXML/objectToString|Edit Descripton]]<nowiki>]</nowiki>
<nowiki>[<! removed edit link to red link >]</nowiki>
</span>
</span>


{{Description:JRegistryFormatXML/objectToString}}
<! removed transcluded page call, red link never existed >


===Syntax===
===Syntax===
Line 59: Line 59:


<span class="editsection" style="font-size:76%;">
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JRegistryFormatXML/objectToString|Edit See Also]]<nowiki>]</nowiki>
<nowiki>[<! removed edit link to red link >]</nowiki>
</span>
</span>
{{SeeAlso:JRegistryFormatXML/objectToString}}
<! removed transcluded page call, red link never existed >


===Examples===
===Examples===
Line 74: Line 74:
  format= ,,,
  format= ,,,
</dpl>
</dpl>
[[Category:Archived pages API15]]

Revision as of 18:44, 12 May 2013

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.


[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

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;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />