Document
class Document extends DOMDocument (View source)
Constants
XML |
Used with |
HTML |
Used with |
JSON |
Used with |
SIMPLE |
Used with |
MINIMAL |
Used with |
COMPLETE |
Used with |
Properties
protected array | $levels | Used with Document::reporting method or in extended classes |
Methods
Create a Document instance
Set level error for exception, set LIBXML_ERR_NONE
(or 0
- zero) for disable exceptions.
Convert a array in node elements
Convert DOM to JSON string
Convert DOM to Array
Magic method, return a well-formed XML string
Get namespace attributes from root element or specific element
Load XML from a string
Load XML from a file
Load HTML from a string
Load HTML from a file
Details
at line 58
void
__construct(string $version = '1.0', string $encoding = 'UTF-8')
Create a Document instance
at line 77
void
reporting()
Set level error for exception, set LIBXML_ERR_NONE
(or 0
- zero) for disable exceptions.
For disable only warnings use like this $dom->reporting(LIBXML_ERR_FATAL, LIBXML_ERR_ERROR)
- 0 - `LIBXML_ERR_NONE` - Disable errors
- 1 - `LIBXML_ERR_WARNING` - Show warnings in DOM
- 2 - `LIBXML_ERR_ERROR` - Show recoverable errors in DOM
- 3 - `LIBXML_ERR_FATAL` - Show DOM fatal errors
at line 89
void
fromArray(array $data)
Convert a array in node elements
at line 124
string
toJson(bool $format = Document::MINIMAL, int $options = 0)
Convert DOM to JSON string
at line 142
array
toArray(int $type = Document::SIMPLE)
Convert DOM to Array
at line 183
string
__toString()
Magic method, return a well-formed XML string
Example:
$xml = new Dom;
$xml->fromArray(array(
'foo' => 'bar'
));
echo $xml;
at line 234
void
getNamespaces(DOMElement $element = null)
Get namespace attributes from root element or specific element
at line 272
mixed
loadXML(string $source, int $options = 0)
Load XML from a string
at line 285
mixed
load(string $filename, int $options = 0)
Load XML from a file
at line 298
mixed
loadHTML(string $source, int $options = 0)
Load HTML from a string
at line 311
mixed
loadHTMLFile(string $filename, int $options = 0)
Load HTML from a file
at line 323
DOMNodeList
query(string $selector, DOMNode $context = null)
Use query-selector like CSS, jQuery, querySelectorAll