XML_Util::collapseEmptyTags

XML_Util::collapseEmptyTags() – collapse empty XML tags in a string

Synopsis

require_once 'XML/Util.php';

string XML_Util::collapseEmptyTags ( string $string , integer $mode = XML_UTIL_COLLAPSE_ALL )

Description

This method collapses empty tags like <foo></foo> with the short version <foo/> by applying a regular expression. This is especially helpful when dealing with XHTML-documents, as there is an important difference in rendering these tags in the browser.

This method has been added in XML_Util 1.1.0.

Parameter

  • string $string - string, in which empty tags should be collapsed

  • integer $mode - collapse all empty tags (XML_UTIL_COLLAPSE_ALL) or only XHTML tags (XML_UTIL_COLLAPSE_XHTML_ONLY).

Return value

string string with collapsed empty tags

Note

This function should be called statically.

create XML attribute string (Previous) create a tag (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.