function collapseEmptyTags($xml, $mode = XML_UTIL_COLLAPSE_ALL) 
    {
        if ($mode == XML_UTIL_COLLAPSE_XHTML_ONLY) {
            return preg_replace(
                '/<(area|base(?:font)?|br|col|frame|hr|img|input|isindex|link|meta|'
                . 'param)([^>]*)><\/\\1>/s',
                '<\\1\\2 />',
                $xml);
        } else {
            return preg_replace('/<(\w+)([^>]*)><\/\\1>/s', '<\\1\\2 />', $xml);
        }
    }
function collapseEmptyTags($xml, $mode = XML_UTIL_COLLAPSE_ALL) 
    {
        if ($mode == XML_UTIL_COLLAPSE_XHTML_ONLY) {
            return preg_replace(
                '/<(area|base(?:font)?|br|col|frame|hr|img|input|isindex|link|meta|'
                . 'param)([^>]*)><\/\\1>/s',
                '<\\1\\2 />',
                $xml);
        } else {
            return preg_replace('/<(\w+)([^>]*)><\/\\1>/s', '<\\1\\2 />', $xml);
        }
    }
function collapseEmptyTags ( $ xml , $ mode = XML_UTIL_COLLAPSE_ALL ) { if ( $ mode == XML_UTIL_COLLAPSE_XHTML_ONLY ) { return preg_replace ( '/<(area|base(?:font)?|br|col|frame|hr|img|input|isindex|link|meta|' . 'param)([^>]*)><\/\\1>/s' , '<\\1\\2 />' , $ xml ) ; } else { return preg_replace ( '/<(\w+)([^>]*)><\/\\1>/s' , '<\\1\\2 />' , $ xml ) ; } }
Collapses empty tags.

@param string $xml  XML
@param int    $mode Whether to collapse all empty tags (XML_UTIL_COLLAPSE_ALL)
or only XHTML (XML_UTIL_COLLAPSE_XHTML_ONLY) ones.

@return string XML
@access public
@static
@todo PEAR CS - unable to avoid "space after open parens" error
in the IF branch
Collapses empty tags .