JTable/toXML
From Joomla! Documentation
< API16:JTable
The "API16" 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]
Method to export the JTable instance properties to an XML string.
Syntax[edit]
toXML($mapKeysToText=false)
Parameter Name | Default Value | Description |
---|---|---|
$mapKeysToText | false | True to map foreign keys to text values. |
Returns[edit]
string XML string representation of the instance.
Defined in[edit]
libraries/joomla/database/table.php
Importing[edit]
jimport( 'joomla.database.table' );
Source Body[edit]
public function toXML($mapKeysToText=false)
{
// Initialise variables.
$xml = array();
$map = $mapKeysToText ? ' mapkeystotext="true"' : '';
// Open root node.
$xml[] = '<record table="'.$this->_tbl.'"'.$map.'>';
// Get the publicly accessible instance properties.
foreach (get_object_vars($this) as $k => $v) {
// If the value is null or non-scalar, or the field is internal ignore it.
if (!is_scalar($v) || ($v === null) || ($k[0] == '_')) {
continue;
}
$xml[] = ' <'.$k.'><![CDATA['.$v.']]></'.$k.'>';
}
// Close root node.
$xml[] = '</record>';
// Return the XML array imploded over new lines.
return implode("\n", $xml);
}
Examples[edit]
Code Examples[edit]