htmldom Class Reference

Detailed Description

DOMDocument for html-content.

Serializable subclass of DOMDocument with helper methods especially for html-content, and for removing up unwanted tags from html.

Definition at line 17 of file htmldom.php.

Inheritance diagram for htmldom:

Public Member Functions

 __construct ($version=null, $encoding=null)
 htmldom class constructor More...
 
 serialize ()
 serializes htmldom into string More...
 
 unserialize ($serialized)
 unserializes htmldom-objects More...
 
 loadHTML ($html)
 loads html from a htmls string More...
 
 cleanHTML ($allowedTags=null)
 cleans up a htmlDOM More...
 
 getBodyNodes ()
 gets a nodelist with all nodes inside the body More...
 

Protected Attributes

 $allowedTags
 Tags that are allowed inside of html. More...
 

Constructor & Destructor Documentation

__construct (   $version = null,
  $encoding = null 
)

htmldom class constructor

Parameters
string$versionxml-version
string$encodingencoding of xml document
Returns
depage::htmlform::abstracts::htmldom htmlDOM

Definition at line 46 of file htmldom.php.

Member Function Documentation

cleanHTML (   $allowedTags = null)

cleans up a htmlDOM

cleans up a htmlDOM and removes all tags and attributes that are not allowed.

Parameters
array$allowedTagsarray of tags that are alowed inside of html
Returns
void

Definition at line 126 of file htmldom.php.

getBodyNodes ( )

gets a nodelist with all nodes inside the body

Returns
nodelist nodes from body

Definition at line 187 of file htmldom.php.

loadHTML (   $html)

loads html from a htmls string

Loads html into the htmldom. Invalid content is allowed. Only nodes inside of the body will be added to the dom.

Parameters
string$htmlhtml to parse
Returns
boolean true on success, false on error

Definition at line 82 of file htmldom.php.

serialize ( )

serializes htmldom into string

Returns
string xml-content saved by saveXML()

Definition at line 55 of file htmldom.php.

unserialize (   $serialized)

unserializes htmldom-objects

Parameters
string$serializedphp-serialized xml string
Returns
void

Definition at line 68 of file htmldom.php.

Field Documentation

$allowedTags
protected
Initial value:
= array(
"p",
"br",
"h1",
"h2",
"ul",
"ol",
"li",
"a",
"b",
"strong",
"i",
"em",
)

Tags that are allowed inside of html.

Definition at line 22 of file htmldom.php.


The documentation for this class was generated from the following file: