class Document (View source)

Constants

ARRAY_SIMPLE

Use with Document::dump or Document::save method to convert document in a simple array

ARRAY_MINIMAL

Use with Document::dump or Document::save method to convert document in a minimal array

ARRAY_COMPLETE

Use with Document::dump or Document::save method to convert document in a array with all properties

HTML

Use for define format

XML

ERROR

Constants to treat errors issued by libXML as exceptions

FATAL

WARNING

Methods

__construct(int $type = 0)

Create a Document instance

static 
setSeverityLevels(int $levels)

Define libXML errors as exceptions

setLoadOptions(int $options)

Define libXML options for load a document or string

setSaveOptions(int $options)

Define libXML options for dump or save a document as file

document()

Get original document

root()

Get root element

selector()

Gets all elements that match the CSS selector

array
getNamespaces(DOMElement $element)

Get namespace attributes from root element or specific element

load(string $source, bool $file = false)

Load string or file

dump(DOMNode $node)

Convert document to XML string, HTML string or array

save(string $file)

Save document to file

fromArray(array $data)

Convert Array to DOM

array
toArray(int $format)

Convert DOM to Array

Details

__construct(int $type = 0)

Create a Document instance

Parameters

int $type

static setSeverityLevels(int $levels)

Define libXML errors as exceptions

Parameters

int $levels

setLoadOptions(int $options)

Define libXML options for load a document or string

Parameters

int $options

setSaveOptions(int $options)

Define libXML options for dump or save a document as file

Parameters

int $options

DOMDocument document()

Get original document

Return Value

DOMDocument

DOMDocument root()

Get root element

Return Value

DOMDocument

Selector selector()

Gets all elements that match the CSS selector

Return Value

Selector

array getNamespaces(DOMElement $element)

Get namespace attributes from root element or specific element

Parameters

DOMElement $element

Return Value

array

load(string $source, bool $file = false)

Load string or file

Parameters

string $source
bool $file

Exceptions

DomException

dump(DOMNode $node)

Convert document to XML string, HTML string or array

Parameters

DOMNode $node

save(string $file)

Save document to file

Parameters

string $file

fromArray(array $data)

Convert Array to DOM

Parameters

array $data

Exceptions

DomException

array toArray(int $format)

Convert DOM to Array

Parameters

int $format

Return Value

array