filter_dom_load

Versions
7
filter_dom_load($text)

Parses an HTML snippet and returns it as a DOM object.

This function loads the body part of a partial (X)HTML document and returns a full DOMDocument object that represents this document. You can use filter_dom_serialize() to serialize this DOMDocument back to a XHTML snippet.

Parameters

$text The partial (X)HTML snippet to load. Invalid mark-up will be corrected on import.

Return value

A DOMDocument that represents the loaded (X)HTML snippet.

▾ 2 functions call filter_dom_load()

_filter_html in modules/filter/filter.module
HTML filter. Provides filtering of input into accepted HTML.
_filter_htmlcorrector in modules/filter/filter.module
Scan input and make sure that all HTML tags are properly closed and nested.

Code

modules/filter/filter.module, line 818

<?php
function filter_dom_load($text) {
  // Ignore warnings during HTML soup loading.
  $dom_document = @DOMDocument::loadHTML('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body>' . $text . '</body></html>');

  return $dom_document;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.