english/libraries/joomla/utilities/xmlelement.php
/**
	 * Return a well-formed XML string based on SimpleXML element
	 *
	 * @param   boolean  $compressed  Should we use indentation and newlines ?
	 * @param   integer  $indent      Indentaion level.
	 *
	 * @return  string
	 * @since   11.1
	 */
Return a well-formed XML string based on SimpleXML element
@param   boolean  $compressed  Should we use indentation and newlines .
@param   integer  $indent      Indentaion level.


Return a well - formed XML string based on SimpleXML element @param boolean $compressed Should we use indentation and newlines . @param integer $indent Indentaion level .
public function asFormattedXML($compressed = false, $indent = "\t", $level = 0)
	{
		$out = '';
		$out .= ($compressed) ? '' : "\n".str_repeat($indent, $level);
		$out .= '<'.$this->getName();
		foreach ($this->attributes() as $attr) {
			$out .= ' '.$attr->getName().'="'.htmlspecialchars((string)$attr, ENT_COMPAT, 'UTF-8').'"';
		}
		if (!count($this->children()) && !(string)$this) {
			$out .= " />";
		} else {
			if (count($this->children())) {
				$out .= '>';
				$level ++;
				foreach ($this->children() as $child) {
					$out .= $child->asFormattedXML($compressed, $indent, $level);
				}
				$level --;
				$out .=($compressed) ? '' : "\n".str_repeat($indent, $level);
			} else if ((string) $this) {
				$out .= '>'.htmlspecialchars((string)$this, ENT_COMPAT, 'UTF-8');
			}
			$out .= '</'.$this->getName().'>';
		}
		return $out;
	}
public function asFormattedXML ( $ compressed = false , $ indent = " \t " , $ level = 0 ) { $ out = '' ; $ out .= ( $ compressed ) ? '' : " \n " . str_repeat ( $ indent , $ level ) ; $ out .= '<' . $ this -> getName ( ) ; foreach ( $ this -> attributes ( ) as $ attr ) { $ out .= ' ' . $ attr -> getName ( ) . '="' . htmlspecialchars ( ( string ) $ attr , ENT_COMPAT , 'UTF-8' ) . '"' ; } if ( ! count ( $ this -> children ( ) ) && ! ( string ) $ this ) { $ out .= "  /> " ; } else { if ( count ( $ this -> children ( ) ) ) { $ out .= '>' ; $ level ++ ; foreach ( $ this -> children ( ) as $ child ) { $ out .= $ child -> asFormattedXML ( $ compressed , $ indent , $ level ) ; } $ level -- ; $ out .= ( $ compressed ) ? '' : " \n " . str_repeat ( $ indent , $ level ) ; } else if ( ( string ) $ this ) { $ out .= '>' . htmlspecialchars ( ( string ) $ this , ENT_COMPAT , 'UTF-8' ) ; } $ out .= '</' . $ this -> getName ( ) . '>' ; } return $ out ; }
Return a well-formed XML string based on SimpleXML element
 @param   boolean  $compressed  Should we use indentation and newlines ?
Return a well - formed XML string based on SimpleXML element @param boolean $compressed Should we use indentation and newlines ?
// Start a new line, indent by the number indicated in $level // Add a <, and add the name of the tag // For each attribute, add attr="value" // If there are no children and it contains no data, end it off with a /> // If there are children // Close off the start tag // For each child, call the asFormattedXML function (this will ensure that all children are added recursively) // Add the newline and indentation to go along with the close tag // If there is data, close off the start tag and add the data // Add the end tag